MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [讨论]【SOS】在matlab中四阶Runge-Kutta法求解常微分方程 (https://www.labfans.com/bbs/showthread.php?t=4175)

kornberg 2008-08-21 09:47

[讨论]【SOS】在matlab中四阶Runge-Kutta法求解常微分方程
 
【SOS】在matlab中四阶Runge-Kutta法求解常微分方程


dx1/dt=x2 x1(0)=1e-8



dx2/dt=x3 x2(0)=0



dx3/dt=x4 x3(0)=0



dx4/dt=f(t,x1,x2,x3,x4) x4(0)=0



求解区间[0,1e-6],在matlab中用四阶Runge-Kutta法求解,


[B]怎么用从一阶循环到四阶?[/B]


[B]有没有类似的具体算例?[/B]



希望各路高人出手相助,关乎小弟能否明年一月份顺利毕业,

在此先多谢各位高人了。

pslpsl 2008-08-21 12:49

回复: [讨论]【SOS】在matlab中四阶Runge-Kutta法求解常微分方程
 
[HTML]dx1/dt=x2 x1(0)=1e-8
dx2/dt=x3 x2(0)=0
dx3/dt=x4 x3(0)=0
dx4/dt=f(t,x1,x2,x3,x4) x4(0)=0

求解区间[0,1e-6],在matlab中用四阶Runge-Kutta法求解,[/HTML]
[FONT=Times New Roman][/FONT]
[SIZE=3][FONT=宋体][/FONT][/SIZE]
[SIZE=3][FONT=宋体]编写函数文件[/FONT][FONT=Times New Roman]verderpol.m[/FONT][FONT=宋体]:[/FONT][/SIZE]
[CODE]
function xprime = verderpol(t,x)
xprime = [x(4);f(t,x1,x2,x3,x4)];
[/CODE]
[FONT=宋体][SIZE=3]再在命令窗口中执行:[/SIZE][/FONT]
[CODE]
>>Y0=[1e-8;0;0;0]
>>[t,x] = ode45(‘verderpol’,0,1e-6,Y0);
>>x1=x(:,1);x2=x(:,2);x3=x(:,3);x4=x(:,4);
>>plot(t,x1,t,x2,t,x3,t,x4)
[/CODE]

kornberg 2008-08-21 13:55

回复: [讨论]【SOS】在matlab中四阶Runge-Kutta法求解常微分方程
 
非常感谢楼上高手指点

我回去试试


所有时间均为北京时间。现在的时间是 11:18

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