0

我正在尝试使用 ODE45 MATLAB 求解非线性微分方程组,我成功地做了很多次,但是这次我得到了以下错误,我真的不知道出了什么问题,我完全糊涂了。这是代码。

%% 这是错误:

Subscript indices must either be real positive integers or logicals.

Error in non_L_ss (line 6)
        (-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;

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

Error in ode45 (line 115)
odearguments(FcnHandlesUsed,solver_name,ode, tspan,y0,optio varargin);

Error in solve (line 50)
[t X]=ode45(@non_L_ss,t_span,IC);

%% 方程被定义在一个函数中:

function dX=non_L_ss(t,x)
global Fk Fc kt Fa q ds0 ms mu 
dX=[ x(2);
     (Fk*(ds0+x(3)-x(1))-Fk*ds0+Fc*(x(4)-x(2))-kt*x(1))/mu-Fa/m-kt*q/mu ;
     x(4);
     (-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;
end

%% ,这里的函数被 ODE45 调用来解决:

clear
clc
global Fk Fc kt Fa q ds0 ms mu qdot v2
mu = 100 ;
ms = 1242 ;
k1s = 80000 ;
k2s = 32000 ;
kt = 405000 ;
c1s = 4000 ;
c2s = 1600 ;
v = 20 ;
Gq = 256e-6 ;
ds0 = 0.1538 ;
a = 1 ;
b = 0.001 ;
n0 = 0.1 ;
f0 = 0.011*v ;
w = 0.5 ;
Fa = 2000 ;
q = 0.05 ;
xs = 0.1 ;
xu = 0.1 ;
dxs = 0.1 ;
dxu = 0.2 ;

Fk = k1s+k2s*(ds0+xs-xu).^2 ;

if dxs >= dxu
Fc = c1s ;
elseif dxs < dxu
Fc = c2s ;
end  

t_span=[0 1];
IC=[2 3 2 2];
[t X]=ode45(@non_L_ss,t_span,IC);
4

1 回答 1

1
Subscript indices must either be real positive integers or logicals.

Error in non_L_ss (line 6)
    (-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;

意味着您将某些东西用作具有非整数索引的索引数组。这可能意味着该对象根本不是数组。我建议更换

Fc(x(4)-x(2))

经过

Fc*(x(4)-x(2))

试图解决这个问题。

于 2017-07-06T19:45:58.977 回答