User`s guide
3 Writing S-Functions As C-MEX files
3-38
Alternatively, you can specify that the sample time is in herited from the
driving block in which case the S-function can have only one sample time pair:
[INHERITED_SAMPLE_TIME, 0.0 ]
or
[INHERITED_SAMPLE_TIME, FIXED_IN_MINOR_STEP_OFFSET]
The following guidelines may help aid in specifying sample times:
• A continuous function that changes during m inor integration steps should
register the
[CONTINUOUS_SAMPLE_TIME, 0.0] sample time.
• A continuous function that does not change during minor integration steps
should register the
[CONTINUOUS_SAMPLE_TIME, FIXED_IN_MINOR_STEP_OFFSET] sample time.
• A discrete function that changes at a specified rate should register the
discrete sample time pair
[discrete_sample_period, offset]
where
discrete_sample_period > 0.0
and
0.0 <= offset < discrete_sample_period
• A discrete function that changes at a variable rate should register the
variable step discrete
[VARIABLE_SAMPLE_TIME, 0.0] sample time. The
mdlGetTimeOfNextVarHit function is called to g et the time of the next
sample hi t for the variable step discrete task. The
VARIABLE_SAMPLE_TIME
can be used with variable step solvers only.
If your function has no intrinsic sample time, then you must indicate that it is
inherited according to the following guidelines:
• A function that changes as its input changes, even during minor integration
steps, should register the
[INHERITED_SAMPLE_TIME, 0.0] sample time.
• A function that changes as its input changes, but doesn't change during
minorintegrationsteps(thatis,heldduring minor steps),shouldregisterthe
[INHERITED_SAMPLE_TIME, FIXED_IN_MINOR_STEP_OFFSET] sample time.