This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: These 2 commands set up the eulers method calculation with a .05 step size. >> plot(t,y,'g:s'); This command plots the eulers estimation on the same graph as the .5 step calculation. >> a=0:.05:6; >> b=.2*exp(a/2)+.8*cos(a)-(8/5)*sin(a); >> plot(a,b,'b:s'); These three commands define the actual function and plot it on the same graph as the approximations. 1 2 3 4 5 6-2-1 1 2 3 4 5 6 3. The two m-file functions are downloaded. Another m-file is created: Function yprime=horse(t,y) Yprime=(1/2)*y-2*cos(t); This file is saved as horse. >>[tr,yr]=rk4(horse,[0,6],1,.05); This command defines the function using the m-file. >>plot(tr,yr,b,s) This command plots the rk4 approximation. We use the same commands as used previously along with rk4 commands to plot the rk4 and the euler approximation on the same graph as the actual equation. 1 2 3 4 5 6-2-1 1 2 3 4 5 6...
View Full Document
This note was uploaded on 07/10/2011 for the course CALC 1301 taught by Professor Marshak during the Spring '11 term at Minnesota.
- Spring '11