Modified Euler's method expansion
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations 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!