|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
本帖最后由 amfk2006 于 2010-10-25 15:34 编辑
Output returned by S-function '***' in '***' during flag=3 call must be a real vector of length 1
单独加常数或正弦输入,没有问题,但是放在大的模型一起仿真,就出现如上错误,请大侠看看,谢谢!
function [sys,x0,str,ts] = mpt(t,x,u,flag,Kc)
switch flag
case 0
[sys,x0,str,ts]=mdlInitializeSizes;
case 2
sys=mdlUpdate(t,x,u);
case 3
sys=mdlOutputs(t,x,u,Kc);
case{1,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes(t,x,u)
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 2;
sizes.NumOutputs = 1;
sizes.NumInputs = 2;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [0 0];
str = [];
ts = [0.001 0];
function sys=mdlUpdate(t,x,u)
sys(1,1) = u(1);
sys(2,1) = u(2);
function sys=mdlOutputs(t,x,u,Kc)
sys = u(1)-u(2);
|
|