ode45解3阶微分方程,2阶我会,3阶就晕了.
方程如下:x'''+tx''-xx'+1=0我的m文件:
function xdot=vdpol(t,x)
xdot(3)=-t*x(3)+x(1)*x(2)-1;
xdot(2)=x(3);
xdot(1)=x(2);
x(1)=x;
窗口命令:
>> t0=0;tf=20;
>> x0=[0;0];
>> [t,x]=ode45('vdpol',[t0,tf],x0);
错误提示:
??? Attempted to access x(3); index out of bounds because numel(x)=2.
Error in ==> vdpol at 2
xdot(3)=-t*x(3)+x(1)*x(2)-1;
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...