square是写在s函数里面的啊,然后用s_function模块调用这个函数就可以了!
s函数如下:
function [sys,x0,str,ts] = maichong(t,x,u,flag) %u是输入的变脉冲频率%
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;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [-1 0];
function sys=mdlOutputs(t,x,u)
sys=square(u*t,1);
嘻嘻,是很简单的问题了。请各位看官指教!
[ 本帖最后由 standdy 于 2007-5-10 12:08 编辑 ] |