How i implement Adams Predictor-Corrector Method from general code ?
Mostra commenti meno recenti

Below is the Adams predictor-corrector formula and general code. How can I adapt this code to the above question? Can you please help?

%------------------------------------------------------
% 2-step Predictor-Corrector
% [T,Y]=dd2(f,definition,y,h); definition=[t1,tfinal]
%------------------------------------------------------
function [T,Y]=dd2(f,definition,Y1,h)
t1=definition(1);tfinal=definition(2);T=t1;Y=Y1;
t2=t1+h;
definition=[t1,t2];
[T,Y]=rk2(f,definition,Y1,h) ;
Y2=Y(2);
while t2 <tfinal
t3=t2+h;
P=Y2+h*(3/2*f(t2,Y2)-1/2*f(t1,Y1));
Y3=Y2+h/12*(5* f(t3,P)+8*f(t2,Y2)-f(t1,Y1));
Y1=Y2; Y2=Y3;t1=t2;t2=t3;
T=[T;t3];Y=[Y;Y3];
end
%
%----------------------------------------------
2 Commenti
Hazel Can
il 27 Mag 2022
Torsten
il 27 Mag 2022
You know the correct result of your differential equation.
If you plot Y against T in the calling program and compare the plot with the analytical solution, both should be approximately the same.
If yes, your code is (most probably) correct, if not, it's not.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Function Creation in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
