EulersMethod - x=x h end e%Exact Values x=x0 0.2 x0 1 ye=2...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
%Eulers Method % x0 = 0; y0=1; x %First Run: h = 0.01; x=x0; y=y0; y1=y0; for n = 1:100 y = y + h*(y-2); y1= [y1,y]; x=x+h; end e %Second Run: h = 0.005; x=x0; y=y0; y2=y0; for n=1:200 y=y+h*(y-2); y2= [y2,y];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x=x+h; end e %Exact Values: x=x0 : 0.2 : x0+1; ye=2 - exp(x); y %Display Table ya = y2(1:40:201); err = 100*(ye-ya) ./ye; e [x; y1(1:20:101); ya; ye; err]...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online