MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] ode45的使用 (https://www.labfans.com/bbs/showthread.php?t=7667)

剑八 2009-04-13 17:39

ode45的使用
 
请问如何使用ode45解
d2x1/dt2=x2-x1;
d2x2/dt2=30+x1-2*x2;
x1(0)=12,x2(0)=23,Dx1(0)=0,Dx2(0)=0

hrt 2009-04-13 20:59

回复: ode45的使用
 
首先建立函数M文件如下:
function dx=fmat(t,x) % x=[x1,x2,x3,x4],其中x3=dx1、x4=dx2;
dx=[x(3);x(4);x(2)-x(1);30+x(1)-2*x(2)];
end

再在命令行中输入:
>> t=0:100;
>> x0=[12,23,0,0];
>> [t,x]=ode45(@fmat,t,x0);
>> [t,x]

可得到结果。
~ ~


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

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