MATLAB.1 Texts: [B-D] Boyce & Diprima, Elementary Diff. Eq. & B.V. Problems, 9th Ed [P-A] Polking & Arnold, ODEs using MATLAB, 2nd Ed A. Getting Started with MATLAB Read Chapters 1 and 3 in Polking. Do this before trying to go on. B. More on Functions Once a function y=g(x) is defined with a M-file you now know how to graph it on an interval [a,b] using the plot command.First you partition [a,b]. Next you evaluate g at these values . The plot command then plots these vertices connecting them by lines to give a piecewise linear approximation to the graph of g. example: Plot sin(x^2) on [-1,4]. First we make a M-file. ************************************************************ function y=g(x) y=sin(x.^2); ************************************************************ Go to the command window and type: *********************************************************** x=-1:.1:4; plot(x,g(x)) title('y=sin(x^2)') *********************************************************** Note x=[-1,-.9,..,3.9,4] and g(x)=[g(-1),g(-.9),..,g(3.9),g(4)] . The graph is pretty crude because g oscillates more as x increases. A second way to graph is with the command fplot. example: (continued) Go to the command window and type: *********************************************************** fplot('g(x)',[-1,4]) *********************************************************** One of the conveniences of fplot is , given g.m , it determines how fine the partition of [a,b] needs to be (what the vector x should be) so that the piecewise linear approximation gives an accurate picture. A second feature of fplot is that it does not require g.m to be written with array smart notation as is required when using plot . CAUTION!! Don't name a function y(x) (that is, use the file y.m); fplot will not plot it. Also fplot only recognizes "x" as the independent variable. So type "fplot('g(x)',[-1,4])" ,not "fplot('g(t)',[-1,4])" even if you used "t" as the independent variable in g.m. ASSIGNMENT 1 : A. a) Let A= 1 7 B= -3 2 C= 3 4 1 0 -3 3 -2 -2 -1 4 0 -4 3 v=[3 5]' w=[2 -9]' x=[-4 3] y=[0 6 -3]. Note []' is the transpose of []. In MATLAB, find from the following the combinations which are not defined and explain in each case why. A*A A*B A*C A.*A A+B A+C A./C A.\B A*x x*A v*A x.*A A.*x y*C C*x C*y A*v A*w x+v v+w x*x v.*w w.*v y.^2 y^2 A^2 x+y v*y v.*y v*w x*w x.*w b) Show that A= 1 -2 and B= -2 -3 commute. 0 3 0 1 B.Graph f(x) = cos(x.^4) on [0,2]. a) Use the plot command with subintervals of length h =.2. b) Use fplot. FOR ALL OF YOUR MATLAB GRAPHING HOMEWORK FOR THIS COURSE TITLE YOUR GRAPHS .