Unformatted text preview: been saved by typing something like the following at a Matlab prompt: >> fcn1(1,3) You should get the value of f (1 , 3). • Your initial value problem will have the form : y = f ( t,y ) y ( t ) = y . Assuming f ( t,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’,[t ,t f ],y ,h) where t and t f are the initial and ﬁnal values of t and h = 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 t f , with given h , using eul , just type the following at a Matlab prompt: >> [t,y]=eul(’fcn1’,[t ,t f ],y ,h); The approximations y ,y 1 ,y 2 ,...,y n are stored in the matrix y . To print them out type : [t,y] To plot them, type : plot(t,y)...
View
Full Document
 Spring '08
 Stefanov
 matlab, Numerical Analysis, Eul, function file, Matlab prompt

Click to edit the document details