Unformatted text preview: something like the following at a Matlab prompt: fcn1(0,3) You should get the value of f (0 , 3). • Your initial value problem should have the form: ( y = f ( x,y ) y ( x ) = y . Assuming f ( x,y ) was saved as the ﬁle fcn1.m , the syntax for eul (as well as rk2 and rk4 , just replace eul ) will be: eul(’fcn1’,[x0,xf],y0,h) where x0 and xf denote the initial and ﬁnal values of x , respectively, y0 is the initial value of y , and h is the step size. (Your version of Matlab may not utilize brackets. Type help eul to ﬁnd out.) To approximate the actual solution to the IVP at xf , with given h , using eul , just type the following at a Matlab prompt: [x,y]=eul(’fcn1’,[x0,xf],y0,h); The approximations y , y 1 , y 2 , . . . , y n are stored in the matrix y • To print them out, type: [x,y] • To plot them, type: plot(x,y)...
View Full Document
- Fall '09