User`s guide

Examples of C MEX-File S-Function Blocks
3-69
during the simulation. In the transfer function used in this example, the
parameters of the transfer function vary with time.
The output of
vsfunc is simply the input u delayed by a variable amount of
time.
mdlOutputs sets the output y equal to state x. mdlUpdate sets the state
vector
x equal to u, the input vector. This example calls
mdlGetTimeOfNextVarHit, an S-function routine that calculates and sets the
“time of next hit,” that is, the time when is
vsfunc is next called. In
mdlGetTimeOfNextVarHit themacrossGetU is used togetapointerto theinput
u. Then this call is made:
ssSetTNext(S, ssGetT(S)(*u[1]));
The macro ssGetT gets the simulation time t. T he second input to the block,
(
*u[1]),isaddedtot, andthe macrossSetTNext setsthetimeofnexthitequal
to
t+(*u[1]), delaying the output by the amount of time set in (*u[1]).