User`s guide

2 Writing S-Functions As M-Files
2-20
function sys = mdlOutputs(t,x,u)
sys = x(1);
% end mdlOutputs
%
%==============================================================
% mdlGetTimeOfNextVarHit
% Return the time of the next hit for this block. Note that the
% result is absolute time.
%==============================================================
%
function sys = mdlGetTimeOfNextVarHit(t,x,u)
sys = t + u(2);
% End of mdlGetTimeOfNextVarHit.
mdlGetTimeOfNextVarHit
returns the “time of the next hit,” the time in the
simulationwhen
vsfunc isnext called. Thismeans that thereis no outputfrom
this S-function until the time of the next hit . In
vsfunc, the time of the next hit
is set to
t + u(2), whichmeans that the secondinput, u(2), sets thetime when
the next call to
vsfunc occurs.
Passing Additional Parameters
Simulink always passes t, x, u,andflag into S-functions. It is poss ible t o pass
additional parameters into yo ur M-file S-function . For an examp le of how to d o
this, se e
limintm.m in the toolbox/simulink/blocks directory.