声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1478|回复: 1

[转帖]简单的积分器

[复制链接]
发表于 2005-11-14 21:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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  &lt;&lt;数值方法(MATLAB版)&gt;&gt;  Version 3   John H.Mathews<BR>%       Book_B  &lt;&lt;数值计算方法&gt;&gt;          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)&lt;=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>
回复
分享到:

使用道具 举报

发表于 2005-11-14 22:10 | 显示全部楼层
简单吗?我看不懂呢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-5 20:49 , Processed in 0.049301 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表