|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
在用similunk仿真时警告为:Error in 'sxinde/S-Function' while executing M-File S-function 'abcd', flag = 2 (update), at time 0. MATLAB error message:
In an assignment A(I) = B, the number of elements in B and
I must be the same.
那是什么原因呀?
S-函数为:function [sys,x0,str,ts] = nevercellPID(t,x,u,flag,k)
switch flag,
case 0,
[sys,x0,str,ts]=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 [sys,x0,str,ts]=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 = [0.1 0.1 0.1 0 0 0];
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)); |
|