'没有足够的输入参数' MATLAB中`ode45`求解器中的错误

时间:2016-11-11 21:45:59

标签: matlab

我想在MATLAB中使用ode45求解器,如下面的代码:

ydot_init=[0 0 0 0 0 0 0 0];
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
[ti,y] = ode45(@(qdot,qddot,t,a,w) func(qdot,qddot,t,a,w),[0 2],ydot_init,options);

和函数funcfunc.m文件中定义:

function f = func(qdot,qddot,t,a,w)
f = zeros(8,1);
f(1) = 0;
f(2) = qddot(2)*t + qdot(2);
f(3) = 0;
f(4) = a*w*cos(w*t);

f(5) = 0;
f(6) = qddot(2);
f(7) = 0;
f(8)=-a*(w^2)*sin(w*t);

请注意,之前的代码中定义了变量qdotqddottaw

但是当我运行我的代码时,它会返回此错误:

Error using @(t,a,w)func(t,a,w)
Not enough input arguments.

Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in Dm (line 116)
[ti,y] = ode45(@(t,a,w) func(t,a,w),[t t+ts],ydot_init',options);

0 个答案:

没有答案