Download MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS User`s guide

Transcript
Introduction
• A discrete S-function that changes at a specified rate 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 at a variable rate should register the
variable step discrete sample time:
[VARIABLE_SAMPLE_TIME, 0.0]
The mdlGetTimeOfNextVarHit routine is called to get the time of the next
sample hit for the variable step discrete task.
If your S-function has no intrinsic sample time, 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
It may be helpful to examine some sample S-functions as you read the next
chapters. Examples are stored in these subdirectories under the MATLAB root
directory:
• M-files: toolbox/simulink/blocks
• C MEX-files: simulink/src
1-13