|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
<P>function [tout,yout] = odeAdamsPC(odefun,tspan,y0)<BR>% <BR>% [TOUT,YOUT] = ODEADAMSPC(ODEFUN,TSPAN,Y0) , 4th order Adams <BR>% Predictor-Corrector Method<BR>% <BR>% 参考书目 <BR>% Book_A <<数值方法(MATLAB版)>> Version 3 John H.Mathews<BR>% Book_B <<数值计算方法>> Version 2 徐涛 <BR>% <BR>% Supported by <BR>% <a href="http://www.dytrol.com/mailtsunshengli@sohu.com,2005-11-01" target="_blank" ><FONT color=#000000>sunshengli@sohu.com,2005-11-01</FONT></A><BR>% </P>
<P><BR>tout=[tspan]; </P>
<P>% RK4起步<BR>if length(tspan)<=4<BR> [tstart,ystart] = odeRK4(odefun,tspan,y0); <BR> tout=[tstart]; <BR>else <BR> [tstart,ystart] = odeRK4(odefun,tspan(1:4),y0);<BR>end<BR>yout = [ystart];</P>
<P>% 4th order Adams Predictor-Correctot Methods<BR>y0 = ystart(:,4);<BR>for n=5:length(tspan)<BR> t = tspan(n);<BR> h = tspan(n)-tspan(n-1);<BR> F = feval( odefun,tspan(n-4:n-1),yout(:,n-4:n-1) );<BR> % Predictor<BR> p = y0 + h/24*(55*F(:,4) - 59*F(:,3) + 37*F(:,2) - 9*F(:,1));<BR> F = [F(:,2) F(:,3) F(:,4) feval(odefun,t,p)];<BR> % Corrector<BR> y0 = y0 + h/24*(9*F(:,4) + 19*F(:,3) - 5*F(:,2) + 1*F(:,1));<BR> F(:,4) = feval(odefun,t,y0);<BR> yout=[yout,y0];<BR>end<BR></P> |
|