Filter löschen
Filter löschen

Modified Euler's method expansion

1 Ansicht (letzte 30 Tage)
PJS KUMAR
PJS KUMAR am 27 Sep. 2018
suggest me to modify the following Euler's method expansion code so as to avoid the calculation of k2 two times
function []=EulerM(fn,a,b,y0,h)
x1=a;
y1=y0;
while(b>x1)
k1=y1+h*feval(fn,x1,y1);
k2=y1+h*(feval(fn,x1,y1)+feval(fn,x1+h,k1))/2;
while(abs(k1-k2)>0.0001)
k1=k2;
k2=y1+h*(feval(fn,x1,y1)+feval(fn,x1+h,k1))/2;
end
x1=x1+h;
y1=k2;
fprintf('when x=%5.2f y=%5.4f\n',x1,y1)
end

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by