请帮我看看这个程序
function = shit(t,x,u,flag,p,omega)k1=1325200;
m1=3.18;
m2=0.29;
c=62.86;
k2=38000;
switch flag,
case 0,
=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u,p,omega,m1,m2,k2,k1,c);
case 2,
sys=mdlUpdate(t,x,u);
case 3,
sys=mdlOutputs(t,x,u);
case 4,
sys=mdlGetTimeOfNextVarHit(t,x,u);
case 9,
sys=mdlTerminate(t,x,u);
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function =mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates= 4;
sizes.NumDiscStates= 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 0;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0= zeros(4,1);
str = [];
ts= ;
function sys=mdlDerivatives(t,x,u,p,omega,m1,m2,k2,k1,c)
x1dot=x(2);
x2dot= p*exp(j*t*omega)/m1-c/m1*(x(2)-x(4))-k2*(x(1)-x(3))/m1;
x3dot=x(3);
x4dot=c/m2*(x(2)-x(4))+k2/m2*(x(1)-x(3));
sys=
end
function sys=mdlUpdate(t,x,u)
sys = [];
function sys=mdlOutputs(t,x,u)
sys = x(1);
function sys=mdlGetTimeOfNextVarHit(t,x,u)
sampleTime = 1; %Example, set the next hit to be one second later.
sys = t + sampleTime;
function sys=mdlTerminate(t,x,u)
sys = [];
% end mdlTerminate
end
利用这个模型仿真后出现State derivatives returned by S-function 'shit' in block 'shit1/S-Function' during flag=1 call must be a real vector of length 4这样的错误,请大家看看怎么改啊? p*exp(j*t*omega)/m1-c/m1*(x(2)-x(4))-k2*(x(1)-x(3))/m1;
这个地方不是实向量.
页:
[1]