Azzera filtri
Azzera filtri

Modified Euler's method expansion

1 visualizzazione (ultimi 30 giorni)
PJS KUMAR
PJS KUMAR il 27 Set 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

Risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by