|
<>我用m-file做一个s-funtion我的输入是u=[1 2],我想通过一定的数学计算使sys=[1×1]的矩阵形式并作为输出,但是不知道为什么系统总是提示错误,说我的sys必需定义成1×2的向量。我试过了,仅仅以让sys=u(1)作为输出,系统都提示错误,高手指点一下什么原因??</P>
<>程序如下
function [sys,x0,str,ts] = times11(t,x,u,flag)
switch flag,
case 0
[sys,x0,str,ts]=mdlInitializeSizes;
case 3
sys=mdlOutputs(t,x,u);
case { 1, 2, 4, 9 }
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts] = mdlInitializeSizes()
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = -1; % dynamically sized
sizes.NumInputs = -1; % dynamically sized
sizes.DirFeedthrough = 1; % has direct feedthrough
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
str = [];
x0 = [];
ts = [-1 0]; % inherited sample time
function sys= mdlOutputs(t,x,u)
sys=u(1);
% end mdlOutputs
请指点
</P> |
|