|
楼主 |
发表于 2007-5-20 20:12
|
显示全部楼层
把时间ts改为〔0 0〕后出现如下提示:Sample times (TS) matrix returned by M-File S-function 'system' in 'time1/S-Function' must be empty。论坛上的有关S-function函数的主题我都看过了。
S-function函数如下:(模型在附件里)
function [sys,x0,str,ts] = system(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u);
case 3,
sys=mdlOutputs(t,x,u);
case {2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 1;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0 = [0];
str = [];
ts = [0 0];
function sys=mdlDerivatives(t,x,u)
sys=[0];
function sys=mdlOutputs(t,x,u)
if u>0
sys=10;
else sys=30;
end |
|