User`s guide
Introduction
1-13
• A discrete S-function that changes at a specified ra te should register the
discrete sample time pair,
[discrete_sample_time_period, offset],
where
discrete_sample_period > 0.0
and
0.0 ≤ offset < discrete_sample_period
• A discrete S-function that changes a t a variable rate should register the
variable step discrete sample time:
[VARIABLE_SAMPLE_TIME, 0.0]
The mdlGetTimeOfNextVarHit routine is called to get the tim e of the next
sample hit for the variable step discrete task.
If your S-function has no intrinsic sample t ime, then you must indicate that
your sample time is inherited. There are two cases:
• An S-function that changes as its input changes, even during minor
integration steps, should register the
[INHERITED_SAMPLE_TIME, 0.0]
sample time.
• An S-function that changes as its input changes, but doesn’t change during
minor integration steps (that is, remains fixed during minor time steps),
should register the
[INHERITED_SAMPLE_TIME, FIXED_IN_MINOR_STEP_OFFSET] sample time.
For example, most discrete-time S-functions must register this sample time
when inheriting the input sample time.
Sample S-Functions
ItmaybehelpfultoexaminesomesampleS-functionsasyoureadthenext
chapters. Examples are storedin these subdirectories under the MATLAB root
directory:
• M-files:
toolbox/simulink/blocks
• CMEX-files:simulink/src