zhuchao12345 发表于 2011-6-17 15:37

S function疑问,sizes.NumSampleTimes疑问

function = zhu(t,x,u,flag)
switch flag
case 0
    =mdlInitializeSizes;
case 3
    sys=mdlOutputs(t,x,u);
case {1,2,4,9}
    sys=[];
otherwise
    error(['Unhandled flag = ',num2str(flag)]);

end

function =mdlInitializeSizes


sizes = simsizes;

sizes.NumContStates= 0;
sizes.NumDiscStates= 0;
sizes.NumOutputs   = 1;
sizes.NumInputs      = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;   % at least one sample time is needed

sys = simsizes(sizes);

%
% initialize the initial conditions
%
x0= [];

%
% str is always an empty matrix
%
str = [];

%
% initialize the array of sample times
%
ts= ;

% end mdlInitializeSizes

%=============================================================================
% mdlOutputs
% Return the block outputs.
%=============================================================================
%
function sys=mdlOutputs(t,x,u)

sys = 0.25*pi*0.0171*8*10^6*(0.027/(0.027-0.25*pi*0.0171*u))^1.2;

% end mdlOutputs
为什么我将sizes.NumSampleTimes =1;改为sizes.NumSampleTimes = 0;就会报错Sample times (TS) matrix returned by M-File S-function 'zhu' in 'untitled/S-Function' must be empty,请各位高手指点一二
页: [1]
查看完整版本: S function疑问,sizes.NumSampleTimes疑问