当我将三阶ODE转换为一阶ODE系统时,我得到了这个:
x1' = x2;
x2' = x3;
x3' = R1*x1+R2*x2-alpha*x3;
x4' = 1;
where
x4 = t;
R1 = -0.000001*(1-cos(theta*x4))-theta*sin(theta*x4)+1;
R2 = -(1-cos(theta*x4));
答案 0 :(得分:3)
您需要创建一个文件,例如diffeq.m
function xdot = diffeq(t, x)
x4 = t;
R1 = -0.000001*(1-cos(theta*x4))-theta*sin(theta*x4)+1;
R2 = -(1-cos(theta*x4));
xdot(1) = x(2);
xdot(2) = x(3);
xdot(3) = R1*x(1)+R2*x(2)-alpha*x(3);
xdot = xdot'; % ODE solver expects a column vector.
然后使用ODE45语法(从这里:http://www.mathworks.com/help/matlab/ref/ode45.html?refresh=true)调用它。
[t,x] = ode45(@diffeq, [tmin tmax], [x1_0, x2_0, x3_0, x4_0]);