This preview shows page 1. Sign up to view the full content.
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