Matlab的ode求解系统 [英] solving system of ode using matlab
本文介绍了Matlab的ode求解系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有9个方程与时间相关系数g
I have 9 equations with a time dependent coefficient g
% MY M file
function dy =tarak(t,y)
G= 3.16;
g = 0.1*exp(-((t-200)/90).^2);
dy=zeros(9,1);
dy(1)=-2*2*y(1)+2*G*y(5)+2*g*y(7);
dy(2)=2*y(1)-2*G*y(5);
dy(3)=2*y(1)-2*g*y(7);
dy(4)=-2*y(4)+g*y(9);
dy(5)=-2*y(5)+G*(y(2)-y(1))+g*y(8);
dy(6)=-2*y(6)-G*y(9);
dy(7)=-2*y(7)+g*(y(3)-y(1))+G*y(8);
dy(8)=-G*y(7)-g*y(5);
dy(9)=G*y(6)-g*y(4);
然后在命令窗口中:
[T,Y] = ode45(@tarak,[0 ,500],[0 0 1 0 0 0 0 0 0])
其中系数G = 3.16
和g = 0.1*exp(-((t-200)/90).^2)
是时间相关系数和时间t = 0:500
;初始条件[0 0 1 0 0 0 0 0 0]
.
where coefficient G = 3.16
and g = 0.1*exp(-((t-200)/90).^2)
is a time dependent coefficient and time t = 0:500
; Initial condition [0 0 1 0 0 0 0 0 0]
.
我得到输出y(1)
,y(2)
的错误负值.有人可以尝试用ode45
解决上述问题吗,以便我可以比较结果.
I'm getting WRONG negative values for output y(1)
, y(2)
. Can someone pls try to solve above eqns with ode45
so that i can compare the results.
推荐答案
在Matlab
中:
options = odeset('AbsTol', 1e-12);
[T,Y] = ode45(@tarak, [0, 500], [0 0 1 0 0 0 0 0 0], options);
这篇关于Matlab的ode求解系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文