

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Fall 2007
Solve problems 2.1, 2.3, 2.13, and 2.17 from “ Numerical Methods with MATLAB” by Gerald Recktenwald.
The objective is to use the ‘lookfor’ command to discover how to find the maximum value in a matrix. Matlab Script File The following script m-file was created for this problem. % "Numerical Methods with MatLab", Gerald Recktenwald % Problem 2. A = [ 1 -5 -2 ; 3 4 -9 ; -7 2 6 ] B = sin(A) Amax = max(max(A)) Bmax = max(max(B)) MATLAB Output
lookfor max Pr_2_ A = 1 -5 - 3 4 - -7 2 6 B = 0.8415 0.9589 -0. 0.1411 -0.7568 -0. -0.6570 0.9093 -0. Amax = 6 Bmax =
Note that the ‘lookfor max’ found a large number of files on my computer and I did not print them all out.
The objective is to use the colon notation to create vectors identical to ones created using ‘linspace’ and ‘logspace’. (a)
x = linspace(0,10,5) x = 0 2.5000 5.0000 7.5000 10. y = 0:2.5: y = 0 2.5000 5.0000 7.5000 10. norm(x-y) ans = 0 (b) x = linspace(-5,5); y = -5:10/99:5; norm(x-y) ans = 3.2935e- (c) x = logspace(1,3,3) x = 10 100 1000 p = 1: p = 1 2 3 y = 10.^p y = 10 100 1000 norm(x-y) ans = 0 (d) x = logspace(1,3,5); p = 1:0.5:3; y = 10.^p; norm(x-y) ans = 0