在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dxdt=zhidao_rk4_5(t,x)
global a b c d r
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
dxdt=[
a*(x2-x1)+x4;
d*x1-x1*x3+c*x2;
x1*x2-b*x3;
x2*x3+r*x4;
];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下面输入:
global a b c d r
a=1;
b=2;
c=3;
d=4;
r=5;
t_end=10; %时间计算的终点,即算到这个时间为止
x0=[1;1;1;1]; %x的初始值
[t,x]=ode45('zhidao_rk4_5',[0,t_end],x0);