MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]还有一个。。 (https://www.labfans.com/bbs/showthread.php?t=5778)

幻紫风 2008-12-11 21:17

[求助]还有一个。。
 
用变形的Euler方法、二阶Heun方法解初值问题
y'=-y+t+1 ,0<=t<=1,y(0)=1;
并Matlab实现。

源代码:
变形的Euler法的MATlAB实现:
function[x,y]=Euler2(dyfun,xspan,y0,h)
x=xspan(1):h:xspan(2);
y(1)=y0;
for n=1:length(x)-1
K1=feval(dyfun,x(n),y(n));
K2=feval(dyfun,x(n)+h/2,y(n)+h*K1/2);
y(n+1)=y(n)+h*K2;
end
format long
x=x';y=y';


所有时间均为北京时间。现在的时间是 09:59

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.