A = [1 2 3 4 5;0 1 2 3 4;0 0 1 2 3;0 0 0 1 2;... 0 0 0 0 1] A = 1 2 3 4 5 0 1 2 3 4 0 0 1 2 3 0 0 0 1 2 0 0 0 0 1 A(:,1) ans = 1 0 0 0 0 A(3,:) ans = 0 0 1 2 3 A(1:2:5,3:5) ans = 3 4 5 1 2 3 0 0 1 x = 1:3:10 x = 1 4 7 10 size(x) ans = 1 4 y = [1:3:10] y = 1 4 7 10 for i = 1:100, for j = 1:100, A(i,j) = i-j; end end size(A) ans = 100 100 A(1:10,1:10) ans = 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 1 0 -1 -2 -3 -4 -5 -6 -7 -8 2 1 0 -1 -2 -3 -4 -5 -6 -7 3 2 1 0 -1 -2 -3 -4 -5 -6 4 3 2 1 0 -1 -2 -3 -4 -5 5 4 3 2 1 0 -1 -2 -3 -4 6 5 4 3 2 1 0 -1 -2 -3 7 6 5 4 3 2 1 0 -1 -2 8 7 6 5 4 3 2 1 0 -1 9 8 7 6 5 4 3 2 1 0 for i = 2:2:100, for j = 5:5:100, A(i,j) = 0; end end A(1:20,1:20) ans = Columns 1 through 12 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 1 0 -1 -2 0 -4 -5 -6 -7 0 -9 -10 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 3 2 1 0 0 -2 -3 -4 -5 0 -7 -8 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 5 4 3 2 0 0 -1 -2 -3 0 -5 -6 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 7 6 5 4 0 2 1 0 -1 0 -3 -4 8 7 6 5 4 3 2 1 0 -1 -2 -3 9 8 7 6 0 4 3 2 1 0 -1 -2 10 9 8 7 6 5 4 3 2 1 0 -1 11 10 9 8 0 6 5 4 3 0 1 0 12 11 10 9 8 7 6 5 4 3 2 1 13 12 11 10 0 8 7 6 5 0 3 2 14 13 12 11 10 9 8 7 6 5 4 3 15 14 13 12 0 10 9 8 7 0 5 4 16 15 14 13 12 11 10 9 8 7 6 5 17 16 15 14 0 12 11 10 9 0 7 6 18 17 16 15 14 13 12 11 10 9 8 7 19 18 17 16 0 14 13 12 11 0 9 8 Columns 13 through 20 -12 -13 -14 -15 -16 -17 -18 -19 -11 -12 0 -14 -15 -16 -17 0 -10 -11 -12 -13 -14 -15 -16 -17 -9 -10 0 -12 -13 -14 -15 0 -8 -9 -10 -11 -12 -13 -14 -15 -7 -8 0 -10 -11 -12 -13 0 -6 -7 -8 -9 -10 -11 -12 -13 -5 -6 0 -8 -9 -10 -11 0 -4 -5 -6 -7 -8 -9 -10 -11 -3 -4 0 -6 -7 -8 -9 0 -2 -3 -4 -5 -6 -7 -8 -9 -1 -2 0 -4 -5 -6 -7 0 0 -1 -2 -3 -4 -5 -6 -7 1 0 0 -2 -3 -4 -5 0 2 1 0 -1 -2 -3 -4 -5 3 2 0 0 -1 -2 -3 0 4 3 2 1 0 -1 -2 -3 5 4 0 2 1 0 -1 0 6 5 4 3 2 1 0 -1 7 6 0 4 3 2 1 0 x = 101; while x>1, if rem(x,2)==0, x = x/2 else x = 3*x+1 end pause end x = 304 x = 152 x = 76 x = 38 x = 19 x = 58 x = 29 x = 88 x = 44 x = 22 x = 11 x = 34 x = 17 x = 52 x = 26 x = 13 x = 40 x = 20 x = 10 x = 5 x = 16 x = 8 x = 4 x = 2 x = 1 x = 3; if x==1, y = 2*x elseif x==2, y = 3*x elseif x==3, y = 4*x else y = 0 end y = 12 type song keyboard %this script will turn Haendel in his grave lalala % and turn him back lalala % and show a demo demo song Clearing all windows to begin the MATLAB Expo Now loading Expo initial screen... (Typing "expomap" will bring up the Expo Main Map without bringing up the initial splash screen) type catch function y = catch(x) while x>1, if rem(x,2)==0, x = x/2 else x = 3*x+1 end pause end y = 0; catch(11) x = 34 x = 17 x = 52 x = 26 x = 13 x = 40 x = 20 x = 10 x = 5 x = 16 x = 8 x = 4 x = 2 x = 1 ans = 0 y y = 12 x x = 3 x = 11 x = 11 y = catch(x) x = 34 x = 17 x = 52 x = 26 x = 13 x = 40 x = 20 x = 10 x = 5 x = 16 x = 8 x = 4 x = 2 x = 1 y = 0 y y = 0 x x = 11 type mypol function y = mypol(x,array1d) % % Evaluates polynomial defined by coefficients in array1d % for variable x. % % array1d must be a onedimensional array. y = 0; n = length(array1d); for k = 1:n, y = y + array1d(k)*x^(k-1); end help mypol Evaluates polynomial defined by coefficients in array1d for variable x. array1d must be a onedimensional array. a = mypol(2,[1,2,3]) a = 17 a = mypol(2,[1,2,3,4]) a = 49 x = 0:0.01:6.28; y = sin(x) y = Columns 1 through 3 0 9.999833334166664e-003 1.999866669333308e-002 Columns 4 through 6 2.999550020249566e-002 3.998933418663416e-002 4.997916927067833e-002 Columns 7 through 9 5.996400647944460e-002 6.994284733753277e-002 7.991469396917270e-002 Columns 10 through 12 8.987854919801104e-002 9.983341664682816e-002 1.097783008371748e-001 Columns 13 through 15 1.197122072889194e-001 1.296341426196948e-001 1.395431146442365e-001 Columns 16 through 18 1.494381324735992e-001 1.593182066142460e-001 1.691823490669960e-001 Columns 19 through 21 1.790295734258242e-001 1.888588949765006e-001 1.986693307950612e-001 Columns 22 through 24 2.084598998460996e-001 2.182296230808693e-001 2.279775235351884e-001 Columns 25 through 27 2.377026264271346e-001 2.474039592545230e-001 2.570805518921551e-001 Columns 28 through 30 2.667314366888312e-001 2.763556485641138e-001 2.859522251048356e-001 Columns 31 through 33 2.955202066613396e-001 3.050586364434435e-001 3.145665606161178e-001 Columns 34 through 36 3.240430283948684e-001 3.334870921408144e-001 3.428978074554514e-001 Columns 37 through 39 3.522742332750900e-001 3.616154319649620e-001 3.709204694129827e-001 Columns 40 through 42 3.801884151231614e-001 3.894183423086505e-001 3.986093279844230e-001 Columns 43 through 45 4.077604530595702e-001 4.168708024292108e-001 4.259394650659996e-001 Columns 46 through 48 4.349655341112302e-001 4.439481069655198e-001 4.528862853790683e-001 Columns 49 through 51 4.617791755414829e-001 4.706258881711580e-001 4.794255386042030e-001 Columns 52 through 54 4.881772468829075e-001 4.968801378437367e-001 5.055333412048469e-001 Columns 55 through 57 5.141359916531132e-001 5.226872289306592e-001 5.311861979208834e-001 Columns 58 through 60 5.396320487339693e-001 5.480239367918736e-001 5.563610229127838e-001 Columns 61 through 63 5.646424733950354e-001 5.728674601004813e-001 5.810351605373051e-001 Columns 64 through 66 5.891447579422695e-001 5.971954413623921e-001 6.051864057360395e-001 Columns 67 through 69 6.131168519734338e-001 6.209859870365597e-001 6.287930240184686e-001 Columns 70 through 72 6.365371822219680e-001 6.442176872376911e-001 6.518337710215366e-001 Columns 73 through 75 6.593846719714731e-001 6.668696350036979e-001 6.742879116281451e-001 Columns 76 through 78 6.816387600233341e-001 6.889214451105513e-001 6.961352386273567e-001 Columns 79 through 81 7.032794192004101e-001 7.103532724176078e-001 7.173560908995228e-001 Columns 82 through 84 7.242871743701426e-001 7.311458297268959e-001 7.379313711099628e-001 Columns 85 through 87 7.446431199708593e-001 7.512804051402927e-001 7.578425628952770e-001 Columns 88 through 90 7.643289370255051e-001 7.707388788989693e-001 7.770717475268238e-001 Columns 91 through 93 7.833269096274834e-001 7.895037396899505e-001 7.956016200363660e-001 Columns 94 through 96 8.016199408837772e-001 8.075581004051143e-001 8.134155047893737e-001 Columns 97 through 99 8.191915683009983e-001 8.248857133384501e-001 8.304973704919705e-001 Columns 100 through 102 8.360259786005205e-001 8.414709848078965e-001 8.468318446180152e-001 Columns 103 through 105 8.521080219493630e-001 8.572989891886034e-001 8.624042272433384e-001 Columns 106 through 108 8.674232255940170e-001 8.723554823449863e-001 8.772005042746817e-001 Columns 109 through 111 8.819578068849475e-001 8.866269144494873e-001 8.912073600614354e-001 Columns 112 through 114 8.956986856800476e-001 9.001004421765051e-001 9.044121893788260e-001 Columns 115 through 117 9.086334961158832e-001 9.127639402605212e-001 9.168031087717668e-001 Columns 118 through 120 9.207505977361356e-001 9.246060124080204e-001 9.283689672491666e-001 Columns 121 through 123 9.320390859672262e-001 9.356160015533858e-001 9.390993563190676e-001 Columns 124 through 126 9.424888019316974e-001 9.457839994495390e-001 9.489846193555862e-001 Columns 127 through 129 9.520903415905158e-001 9.551008555846922e-001 9.580158602892250e-001 Columns 130 through 132 9.608350642060726e-001 9.635581854171930e-001 9.661849516127340e-001 Columns 133 through 135 9.687151001182652e-001 9.711483779210446e-001 9.734845416953194e-001 Columns 136 through 138 9.757233578266590e-001 9.778646024353162e-001 9.799080613986142e-001 Columns 139 through 141 9.818535303723598e-001 9.837008148112766e-001 9.854497299884602e-001 Columns 142 through 144 9.871001010138504e-001 9.886517628517198e-001 9.901045603371778e-001 Columns 145 through 147 9.914583481916864e-001 9.927129910375884e-001 9.938683634116448e-001 Columns 148 through 150 9.949243497775810e-001 9.958808445376400e-001 9.967377520431434e-001 Columns 151 through 153 9.974949866040544e-001 9.981524724975482e-001 9.987101439755830e-001 Columns 154 through 156 9.991679452714760e-001 9.995258306054790e-001 9.997837641893570e-001 Columns 157 through 159 9.999417202299664e-001 9.999996829318346e-001 9.999576464987400e-001 Columns 160 through 162 9.998156151342908e-001 9.995736030415052e-001 9.992316344213906e-001 Columns 163 through 165 9.987897434705240e-001 9.982479743776324e-001 9.976063813191736e-001 Columns 166 through 168 9.968650284539188e-001 9.960239899165368e-001 9.950833498101802e-001 Columns 169 through 171 9.940432021980760e-001 9.929036510941184e-001 9.916648104524686e-001 Columns 172 through 174 9.903268041561580e-001 9.888897660047014e-001 9.873538397007164e-001 Columns 175 through 177 9.857191788355534e-001 9.839859468739370e-001 9.821543171376184e-001 Columns 178 through 180 9.802244727880454e-001 9.781966068080446e-001 9.760709219825242e-001 Columns 181 through 183 9.738476308781952e-001 9.715269558223152e-001 9.691091288804564e-001 Columns 184 through 186 9.665943918332976e-001 9.639829961524480e-001 9.612752029752998e-001 Columns 187 through 189 9.584712830789142e-001 9.555715168529440e-001 9.525761942715954e-001 Columns 190 through 192 9.494856148646304e-001 9.463000876874144e-001 9.430199312900104e-001 Columns 193 through 195 9.396454736853250e-001 9.361770523163062e-001 9.326150140222004e-001 Columns 196 through 198 9.289597150038694e-001 9.252115207881682e-001 9.213708061913954e-001 Columns 199 through 201 9.174379552818098e-001 9.134133613412252e-001 9.092974268256818e-001 Columns 202 through 204 9.050905633252008e-001 9.007931915226272e-001 8.964057411515598e-001 Columns 205 through 207 8.919286509533796e-001 8.873623686333755e-001 8.827073508159741e-001 Columns 208 through 210 8.779640629990781e-001 8.731329795075164e-001 8.682145834456126e-001 Columns 211 through 213 8.632093666488737e-001 8.581178296348089e-001 8.529404815528762e-001 Columns 214 through 216 8.476778401335698e-001 8.423304316366457e-001 8.368987907984977e-001 Columns 217 through 219 8.313834607786831e-001 8.257849931056080e-001 8.201039476213742e-001 Columns 220 through 222 8.143408924257960e-001 8.084964038195901e-001 8.025710662467472e-001 Columns 223 through 225 7.965654722360865e-001 7.904802223420048e-001 7.843159250844198e-001 Columns 226 through 228 7.780731968879212e-001 7.717526620201257e-001 7.653549525292536e-001 Columns 229 through 231 7.588807081809218e-001 7.523305763941707e-001 7.457052121767200e-001 Columns 232 through 234 7.390052780594708e-001 7.322314440302514e-001 7.253843874668195e-001 Columns 235 through 237 7.184647930691263e-001 7.114733527908443e-001 7.044107657701763e-001 Columns 238 through 240 6.972777382599378e-001 6.900749835569364e-001 6.828032219306397e-001 Columns 241 through 243 6.754631805511510e-001 6.680555934164910e-001 6.605812012792007e-001 Columns 244 through 246 6.530407515722648e-001 6.454349983343707e-001 6.377647021345036e-001 Columns 247 through 249 6.300306299958922e-001 6.222335553193047e-001 6.143742578057118e-001 Columns 250 through 252 6.064535233783147e-001 5.984721441039565e-001 5.904309181139127e-001 Columns 253 through 255 5.823306495240819e-001 5.741721483545723e-001 5.659562304487028e-001 Columns 256 through 258 5.576837173914166e-001 5.493554364271266e-001 5.409722203769886e-001 Columns 259 through 261 5.325349075556212e-001 5.240443416872761e-001 5.155013718214642e-001 Columns 262 through 264 5.069068522480534e-001 4.982616424118386e-001 4.895666068265995e-001 Columns 265 through 267 4.808226149886483e-001 4.720305412898826e-001 4.631912649303452e-001 Columns 268 through 270 4.543056698303065e-001 4.453746445418712e-001 4.363990821601263e-001 Columns 271 through 273 4.273798802338298e-001 4.183179406756590e-001 4.092141696720173e-001 Columns 274 through 276 4.000694775924195e-001 3.908847788984522e-001 3.816609920523316e-001 Columns 277 through 279 3.723990394250553e-001 3.630998472041683e-001 3.537643453011427e-001 Columns 280 through 282 3.443934672583900e-001 3.349881501559046e-001 3.255493345175600e-001 Columns 283 through 285 3.160779642170538e-001 3.065749863835230e-001 2.970413513068324e-001 Columns 286 through 288 2.874780123425444e-001 2.778859258165868e-001 2.682660509296179e-001 Columns 289 through 291 2.586193496611108e-001 2.489467866731526e-001 2.392493292139824e-001 Columns 292 through 294 2.295279470212642e-001 2.197836122251170e-001 2.100172992508992e-001 Columns 295 through 297 2.002299847217705e-001 1.904226473610270e-001 1.805962678942329e-001 Columns 298 through 300 1.707518289511453e-001 1.608903149674558e-001 1.510127120863438e-001 Columns 301 through 303 1.411200080598672e-001 1.312131921501838e-001 1.212932550306298e-001 Columns 304 through 306 1.113611886866496e-001 1.014179863166019e-001 9.146464223243674e-002 Columns 307 through 309 8.150215176026912e-002 7.153151114084326e-002 6.155371742991315e-002 Columns 310 through 312 5.156976839853464e-002 4.158066243329049e-002 3.158739843645390e-002 Columns 313 through 315 2.159097572609596e-002 1.159239393615828e-002 1.592652916486828e-003 Columns 316 through 318 -8.407247367148618e-003 -1.840630693305381e-002 -2.840352588360379e-002 Columns 319 through 321 -3.839790450523538e-002 -4.838844336841415e-002 -5.837414342758009e-002 Columns 322 through 324 -6.835400612104778e-002 -7.832703347086530e-002 -8.829222818260760e-002 Columns 325 through 327 -9.824859374510868e-002 -1.081951345301084e-001 -1.181308558918178e-001 Columns 328 through 330 -1.280547642663797e-001 -1.379658672712273e-001 -1.478631738043185e-001 Columns 331 through 333 -1.577456941432486e-001 -1.676124400442183e-001 -1.774624248408606e-001 Columns 334 through 336 -1.872946635429032e-001 -1.971081729346698e-001 -2.069019716733998e-001 Columns 337 through 339 -2.166750803873796e-001 -2.264265217738832e-001 -2.361553206968970e-001 Columns 340 through 342 -2.458605042846370e-001 -2.555411020268312e-001 -2.651961458717734e-001 Columns 343 through 345 -2.748246703231240e-001 -2.844257125364626e-001 -2.939983124155676e-001 Columns 346 through 348 -3.035415127084294e-001 -3.130543591029702e-001 -3.225359003224790e-001 Columns 349 through 351 -3.319851882207341e-001 -3.414012778768210e-001 -3.507832276896198e-001 Columns 352 through 354 -3.601300994719686e-001 -3.694409585444771e-001 -3.787148738289980e-001 Columns 355 through 357 -3.879509179417303e-001 -3.971481672859602e-001 -4.063057021444168e-001 Columns 358 through 360 -4.154226067712462e-001 -4.244979694835826e-001 -4.335308827527178e-001 Columns 361 through 363 -4.425204432948524e-001 -4.514657521614232e-001 -4.603659148289983e-001 Columns 364 through 366 -4.692200412887271e-001 -4.780272461353429e-001 -4.867866486556994e-001 Columns 367 through 369 -4.954973729168449e-001 -5.041585478536115e-001 -5.127693073557238e-001 Columns 370 through 372 -5.213287903544065e-001 -5.298361409084934e-001 -5.382905082900177e-001 Columns 373 through 375 -5.466910470692872e-001 -5.550369171994238e-001 -5.633272841003700e-001 Columns 376 through 378 -5.715613187423437e-001 -5.797381977287431e-001 -5.878571033784827e-001 Columns 379 through 381 -5.959172238077642e-001 -6.039177530112606e-001 -6.118578909427193e-001 Columns 382 through 384 -6.197368435949633e-001 -6.275538230792936e-001 -6.353080477042756e-001 Columns 385 through 387 -6.429987420539088e-001 -6.506251370651673e-001 -6.581864701049049e-001 Columns 388 through 390 -6.656819850461192e-001 -6.731109323435617e-001 -6.804725691086940e-001 Columns 391 through 393 -6.877661591839738e-001 -6.949909732164720e-001 -7.021462887308054e-001 Columns 394 through 396 -7.092313902013861e-001 -7.162455691239705e-001 -7.231881240865121e-001 Columns 397 through 399 -7.300583608392995e-001 -7.368555923643834e-001 -7.435791389442746e-001 Columns 400 through 402 -7.502283282299190e-001 -7.568024953079282e-001 -7.633009827670734e-001 Columns 403 through 405 -7.697231407640244e-001 -7.760683270883323e-001 -7.823359072266528e-001 Columns 406 through 408 -7.885252544261950e-001 -7.946357497573974e-001 -8.006667821758177e-001 Columns 409 through 411 -8.066177485832405e-001 -8.124880538879843e-001 -8.182771110644103e-001 Columns 412 through 414 -8.239843412116258e-001 -8.296091736113709e-001 -8.351510457850935e-001 Columns 415 through 417 -8.406094035501945e-001 -8.459837010754465e-001 -8.512734009355745e-001 Columns 418 through 420 -8.564779741650012e-001 -8.615969003107405e-001 -8.666296674844443e-001 Columns 421 through 423 -8.715757724135882e-001 -8.764347204918014e-001 -8.812060258283253e-001 Columns 424 through 426 -8.858892112966027e-001 -8.904838085819885e-001 -8.949893582285835e-001 Columns 427 through 429 -8.994054096851777e-001 -9.037315213503056e-001 -9.079672606164054e-001 Columns 430 through 432 -9.121122039130804e-001 -9.161659367494550e-001 -9.201280537556240e-001 Columns 433 through 435 -9.239981587231880e-001 -9.277758646448754e-001 -9.314607937532426e-001 Columns 436 through 438 -9.350525775584494e-001 -9.385508568851078e-001 -9.419552819082010e-001 Columns 439 through 441 -9.452655121880634e-001 -9.484812167044256e-001 -9.516020738895160e-001 Columns 442 through 444 -9.546277716602164e-001 -9.575580074492712e-001 -9.603924882355434e-001 Columns 445 through 447 -9.631309305733166e-001 -9.657730606206388e-001 -9.683186141667072e-001 Columns 448 through 450 -9.707673366582882e-001 -9.731189832251738e-001 -9.753733187046664e-001 Columns 451 through 453 -9.775301176650970e-001 -9.795891644283668e-001 -9.815502530915156e-001 Columns 454 through 456 -9.834131875473108e-001 -9.851777815038594e-001 -9.868438585032366e-001 Columns 457 through 459 -9.884112519391306e-001 -9.898798050735040e-001 -9.912493710522670e-001 Columns 460 through 462 -9.925198129199632e-001 -9.936910036334646e-001 -9.947628260746756e-001 Columns 463 through 465 -9.957351730622454e-001 -9.966079473622856e-001 -9.973810616980932e-001 Columns 466 through 468 -9.980544387588794e-001 -9.986280112074988e-001 -9.991017216871848e-001 Columns 469 through 471 -9.994755228272840e-001 -9.997493772479940e-001 -9.999232575641008e-001 Columns 472 through 474 -9.999971463877180e-001 -9.999710363300244e-001 -9.998449300020044e-001 Columns 475 through 477 -9.996188400141854e-001 -9.992927889753780e-001 -9.988668094904142e-001 Columns 478 through 480 -9.983409441568876e-001 -9.977152455608934e-001 -9.969897762717696e-001 Columns 481 through 483 -9.961646088358406e-001 -9.952398257691626e-001 -9.942155195492714e-001 Columns 484 through 486 -9.930917926059354e-001 -9.918687573109126e-001 -9.905465359667132e-001 Columns 487 through 489 -9.891252607943698e-001 -9.876050739202154e-001 -9.859861273616704e-001 Columns 490 through 492 -9.842685830120416e-001 -9.824526126243324e-001 -9.805383977940690e-001 Columns 493 through 495 -9.785261299411386e-001 -9.764160102906498e-001 -9.742082498528090e-001 Columns 496 through 498 -9.719030694018208e-001 -9.695006994538088e-001 -9.670013802437660e-001 Columns 499 through 501 -9.644053617015304e-001 -9.617129034267934e-001 -9.589242746631384e-001 Columns 502 through 504 -9.560397542711180e-001 -9.530596307003674e-001 -9.499842019607608e-001 Columns 505 through 507 -9.468137755926090e-001 -9.435486686359066e-001 -9.401892075986284e-001 Columns 508 through 510 -9.367357284240790e-001 -9.331885764572976e-001 -9.295481064105250e-001 Columns 511 through 513 -9.258146823277322e-001 -9.219886775482162e-001 -9.180704746692670e-001 Columns 514 through 516 -9.140604655079070e-001 -9.099590510617106e-001 -9.057666414687044e-001 Columns 517 through 519 -9.014836559663548e-001 -8.971105228496424e-001 -8.926476794282346e-001 Columns 520 through 522 -8.880955719827542e-001 -8.834546557201531e-001 -8.787253947281899e-001 Columns 523 through 525 -8.739082619290224e-001 -8.690037390319161e-001 -8.640123164850744e-001 Columns 526 through 528 -8.589344934265920e-001 -8.537707776345433e-001 -8.485216854762041e-001 Columns 529 through 531 -8.431877418564168e-001 -8.377694801650978e-001 -8.322674422239013e-001 Columns 532 through 534 -8.266821782320357e-001 -8.210142467112470e-001 -8.152642144499634e-001 Columns 535 through 537 -8.094326564466194e-001 -8.035201558521553e-001 -7.975273039117042e-001 Columns 538 through 540 -7.914546999054660e-001 -7.853029510887806e-001 -7.790726726314031e-001 Columns 541 through 543 -7.727644875559871e-001 -7.663790266757844e-001 -7.599169285315610e-001 Columns 544 through 546 -7.533788393277465e-001 -7.467654128678123e-001 -7.400773104888944e-001 Columns 547 through 549 -7.333152009956565e-001 -7.264797605934131e-001 -7.195716728205075e-001 Columns 550 through 552 -7.125916284799615e-001 -7.055403255703919e-001 -6.984184692162135e-001 Columns 553 through 555 -6.912267715971264e-001 -6.839659518769007e-001 -6.766367361314569e-001 Columns 556 through 558 -6.692398572762620e-001 -6.617760549930369e-001 -6.542460756557914e-001 Columns 559 through 561 -6.466506722561834e-001 -6.389906043282237e-001 -6.312666378723208e-001 Columns 562 through 564 -6.234795452786853e-001 -6.156301052500863e-001 -6.077191027239858e-001 Columns 565 through 567 -5.997473287940438e-001 -5.917155806310094e-001 -5.836246614030073e-001 Columns 568 through 570 -5.754753801952172e-001 -5.672685519289686e-001 -5.590049972802488e-001 Columns 571 through 573 -5.506855425976376e-001 -5.423110198196698e-001 -5.338822663916443e-001 Columns 574 through 576 -5.254001251818793e-001 -5.168654443974288e-001 -5.082790774992584e-001 Columns 577 through 579 -4.996418831169024e-001 -4.909547249626010e-001 -4.822184717449315e-001 Columns 580 through 582 -4.734339970819351e-001 -4.646021794137574e-001 -4.557239019148047e-001 Columns 583 through 585 -4.468000524054300e-001 -4.378315232631469e-001 -4.288192113333959e-001 Columns 586 through 588 -4.197640178398589e-001 -4.106668482943408e-001 -4.015286124062146e-001 Columns 589 through 591 -3.923502239914538e-001 -3.831326008812514e-001 -3.738766648302360e-001 Columns 592 through 594 -3.645833414243013e-001 -3.552535599880426e-001 -3.458882534918288e-001 Columns 595 through 597 -3.364883584585042e-001 -3.270548148697406e-001 -3.175885660720348e-001 Columns 598 through 600 -3.080905586823781e-001 -2.985617424935936e-001 -2.890030703793612e-001 Columns 601 through 603 -2.794154981989258e-001 -2.697999847015162e-001 -2.601574914304680e-001 Columns 604 through 606 -2.504889826270749e-001 -2.407954251341592e-001 -2.310777882993922e-001 Columns 607 through 609 -2.213370438783587e-001 -2.115741659373850e-001 -2.017901307561289e-001 Columns 610 through 612 -1.919859167299550e-001 -1.821625042720950e-001 -1.723208757156102e-001 Columns 613 through 615 -1.624620152151542e-001 -1.525869086485612e-001 -1.426965435182577e-001 Columns 616 through 618 -1.327919088525168e-001 -1.228739951065500e-001 -1.129437940634674e-001 Columns 619 through 621 -1.030022987350978e-001 -9.305050326268890e-002 -8.308940281749640e-002 Columns 622 through 624 -7.311999350126308e-002 -6.314327224661277e-002 -5.316023671735613e-002 Columns 625 through 627 -4.317188520872868e-002 -3.317921654755682e-002 -2.318322999237945e-002 Columns 628 through 629 -1.318492513352125e-002 -3.185301793137990e-003 figure(1) plot(x,y,'ro') zoom plot(x,y,'r') hold Current plot held y2 = cos(x); plot(x,y2,'b') figure(2) plot(y,y2,'y') hold Current plot held y = sin(4*x); y2 = sin(3*x); plot(y,y2,'b') y = sin(7*x); hold Current plot released plot(y,y2,'b') hold Current plot held title('Lissajou') xlabel('x-axis') ylabel('y-axis') legend('blue some function','red absent') help legend LEGEND Graph legend. LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND(linetype1,string1,linetype2,string2, ...) specifies the line types/colors for each label. Linetypes can be any valid PLOT linetype. LEGEND(h,...) puts a legend on the plot with handle h. LEGEND(M), where M is a string matrix, and LEGEND(H,M) where H is a vector of handles to lines also works. LEGEND OFF removes the legend from the current axes. LEGEND(...,TOL) sets the tolerance for covering data points. If LEGEND finds no location where less than TOL data points are covered, LEGEND resizes the plot and places the legend outside. TOL = -1 forces the legend to be placed outside the plot. TOL = 0 places the legend on the plot unless no location can be found that will not obscure data points. To move the legend, press the left mouse button on the legend and drag to the desired location. Examples: x = 0:.2:12; plot(x,bessel(1,x),x,bessel(2,x),x,bessel(3,x)); legend('First','Second','Third'); legend('First','Second','Third',-1) To avoid grid or plot lines obscuring the legend, make the legend the current axes before printing. For example: h=legend('string') axes(h) print When the legend axes are made the current axes, the figure window may not be redrawn. To force a redraw, use REFRESH. See also REFRESH, PLOT. type laplce function A = laplce(n) % % creates matrix for solving nxn laplace equation N = n*n; d0 = -4*ones(N,1); d1 = ones(N,1); A = spdiags([d1 d1 d0 d1 d1],[-n -1 0 1 n],100,100); % set coefficients corresponding to points % next to boundary to 0 for k = 1:n-1, A(k*n,k*n+1) = 0; A(k*n+1,k*n) = 0; end A = laplce(10); spy(A) figure(3) spy(A) Af = full(A); A(1:20,1:20) ans = (1,1) -4 (2,1) 1 (11,1) 1 (1,2) 1 (2,2) -4 (3,2) 1 (12,2) 1 (2,3) 1 (3,3) -4 (4,3) 1 (13,3) 1 (3,4) 1 (4,4) -4 (5,4) 1 (14,4) 1 (4,5) 1 (5,5) -4 (6,5) 1 (15,5) 1 (5,6) 1 (6,6) -4 (7,6) 1 (16,6) 1 (6,7) 1 (7,7) -4 (8,7) 1 (17,7) 1 (7,8) 1 (8,8) -4 (9,8) 1 (18,8) 1 (8,9) 1 (9,9) -4 (10,9) 1 (19,9) 1 (9,10) 1 (10,10) -4 (20,10) 1 (1,11) 1 (11,11) -4 (12,11) 1 (2,12) 1 (11,12) 1 (12,12) -4 (13,12) 1 (3,13) 1 (12,13) 1 (13,13) -4 (14,13) 1 (4,14) 1 (13,14) 1 (14,14) -4 (15,14) 1 (5,15) 1 (14,15) 1 (15,15) -4 (16,15) 1 (6,16) 1 (15,16) 1 (16,16) -4 (17,16) 1 (7,17) 1 (16,17) 1 (17,17) -4 (18,17) 1 (8,18) 1 (17,18) 1 (18,18) -4 (19,18) 1 (9,19) 1 (18,19) 1 (19,19) -4 (20,19) 1 (10,20) 1 (19,20) 1 (20,20) -4 Af(1:20,1:20) ans = Columns 1 through 12 -4 1 0 0 0 0 0 0 0 0 1 0 1 -4 1 0 0 0 0 0 0 0 0 1 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 0 0 0 0 1 -4 0 0 1 0 0 0 0 0 0 0 0 0 -4 1 0 1 0 0 0 0 0 0 0 0 1 -4 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 Columns 13 through 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 1 0 0 0 0 0 0 1 -4 b = zeros(100,1); b(1:10,1) = [1 1 1 1 1 1 1 1 1 1]; ??? In an assignment A(matrix,matrix) = B, the number of rows in B and the number of elements in the A row index matrix must be the same. b(1:10,1) = [1 1 1 1 1 1 1 1 1 1]'; x = A\b; x2 = reshape(x,10,10); figure(1) mesh(x2) hold Current plot released mesh(x2) surf(x2) colormap('cool') help view VIEW 3-D graph viewpoint specification. VIEW(AZ,EL) and VIEW([AZ,EL]) set the angle of the view from which an observer sees the current 3-D plot. AZ is the azimuth or horizontal rotation and EL is the vertical elevation (both in degrees). Azimuth revolves about the z-axis, with positive values indicating counter- clockwise rotation of the viewpoint. Positive values of elevation correspond to moving above the object; negative values move below. VIEW([X Y Z]) sets the view angle in cartesian coordinates. The magnitude of vector X,Y,Z is ignored. Here are some examples: AZ = -37.5, EL = 30 is the default 3-D view. AZ = 0, EL = 90 is directly overhead and the default 2-D view. AZ = EL = 0 looks directly up the first column of the matrix. AZ = 180 is behind the matrix. VIEW(2) sets the default 2-D view, AZ = 0, EL = 90. VIEW(3) sets the default 3-D view, AZ = -37.5, EL = 30. [AZ,EL] = VIEW returns the current azimuth and elevation. VIEW(T) accepts a 4-by-4 transformation matrix, such as the perspective transformations generated by VIEWMTX. T = VIEW returns the current general 4-by-4 transformation matrix. See also VIEWMTX, the AXES properties View, Xform. for k = 10:10:360, end [az,el] = view az = -3.750000000000000e+001 el = 30 for k = 10:10:360, view(az+k,el); pause end help shading SHADING Color shading mode. SHADING controls the color shading of SURFACE and PATCH objects. SURFACE and PATCH objects are created by the functions SURF, MESH, PCOLOR, FILL, and FILL3. SHADING FLAT sets the shading of the current graph to flat. SHADING INTERP sets the shading to interpolated. SHADING FACETED sets the shading to faceted, which is the default. Flat shading is piecewise constant; each mesh line segment or surface patch has a constant color determined by the color value at the end point of the segment or the corner of the patch which has the smallest index or indices. Interpolated shading, which is also known as Gouraud shading, is piecewise bilinear; the color in each segment or patch varies linearly and interpolates the end or corner values. Faceted shading is flat shading with superimposed black mesh lines. This is often the most effective and is the default. SHADING is an M-file that sets the EdgeColor and FaceColor properties of all SURFACE objects in the current axes. It sets them to the correct values that depend upon whether the SURFACE objects are representing meshes or surfaces. See also SURF, MESH, PCOLOR, FILL, FILL3, SURFACE, PATCH. shading flat shading interp shading faceted shading interp for k = 10:10:360, view(az+k,el); pause end b = zeros(100,1); b(45) = 1; x = A\b; x2 = reshape(x,10,10); surf(x2) surf(-x2) [v,s] = eig(A); ??? Error using ==> eig For sparse eigenvectors, use [V,D] = eig(full(S)). [v,s] = eig(full(A)); s = diag(s); figure(2) hold Current plot released plot(s) close(2) figure(2) plot(s) [ss,idx] = sort(s); figure(2) hold Current plot held plot(ss,'bo') figure(1) w = reshape(v(:,idx(100)),10,10); surf(w) w = reshape(v(:,idx(99)),10,10); surf(w) [az,el] = view; for k = 10:10:360, view(az+k,el+k) pause end w = reshape(v(:,idx(90)),10,10); surf(w) colormap('gray') colormap('bone') shading intrp ??? Error using ==> shading Shading methods are flat, faceted, and interp. shading interp flops ans = 17260208 tic, inv(A), toc -- inv(A) printed out -- elapsed_time = 4.399999999999998e+000 tic, inv(A); toc elapsed_time = 6.000000000000050e-002 t0 = clock; svd(full(A)); etime(clock,t0) ans = 1.100000000000030e-001 clock ans = Columns 1 through 3 1.999000000000000e+003 8.000000000000000e+000 2.700000000000000e+001 Columns 4 through 6 0 2.100000000000000e+001 4.497000000000000e+001 format short e clock ans = 1999 8 27 0 21 57 cputime ans = 0 cputime ans = 8.0200e+000 t0 = cputime; svd(full(A)); cputime-t0 ans = 1.1000e-001 t0 t0 = 3.5100e+001 format long e t0 t0 = 3.510000000000000e+001 format compact t0 t0 = 3.510000000000000e+001 diary off