zengyuping 发表于 2009-3-30 23:05

警告为In an assignment A(I) = B, the number of elements in B and

在用similunk仿真时警告为:Error in 'sxinde/S-Function' while executing M-File S-function 'abcd', flag = 2 (update), at time 0. MATLAB error message:
In an assignmentA(I) = B, the number of elements in B and
I must be the same.
那是什么原因呀?


S-函数为:function = nevercellPID(t,x,u,flag,k)
switch flag,
case 0,
    =mdlInitializeSizes;
case 2,
    sys=mdlUpdate(t,x,u);
case 3,
    sys=mdlOutputs(t,x,u,k);
case {1,4,9}
    sys=[]
otherwise
    error(['Unhandled flag = ',num2str(flag)]);
end
function =mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates= 0;
sizes.NumDiscStates= 6;
sizes.NumOutputs   = 1;
sizes.NumInputs      = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;   % at least one sample time is needed
sys = simsizes(sizes);
x0= ;
str = [];
ts= [];
function sys=mdlUpdate(t,x,u)
x(6)=u-x(5)-x(4);
x(4)=u-x(5);
x(5)=u;
x(1)=x(1)+20*u*x(4);
x(2)=x(2)+5*u*x(5);
x(3)=x(3)+10*u*x(6);
function sys=mdlOutputs(t,x,u,k)
sys=k*(x(1)*x(4)+x(2)*x(5)+x(3)*x(6))/(x(1)+x(2)+x(3));

yufeng 发表于 2009-3-31 08:55

在更新那里有错误 看看你的u

zengyuping 发表于 2009-4-1 16:39

哦,确实是我的u弄错了,现在好了,谢谢你啊!
页: [1]
查看完整版本: 警告为In an assignment A(I) = B, the number of elements in B and