User`s guide
Overview of the C MEX S-Function Routines
3-37
Specifying the Number of Sample Times in mdlInitializeSizes. To configure your
S-function block for block-based sample times, use
ssSetNumSampleTimes(S,numSampleTimes);
where numSampleTimes > 0. This tells S imulink that your S-function has
block-based sample times . Simulink c alls
mdlInitializeSampleTimes,which
in turn sets the sample times.
Setting Sample Times and Specifying Function Calls in mdlInitializeSampleTimes.
mdlInitializeSampleTimes
is used to specify t wo pieces of execution
information:
• Sample and offset times — In
mdlInitializeSizes, specify the number of
sample times you’d like your S-function to have by using the
ssSetNumSampleTimes macro. In mdlInitializeSampleTimes, you must
specify the sampling period a nd offset for e ach sample time.
Sample times can be a function of t he input/output port widths. In
mdlInitializeSampleTimes, you can specify that sample times are a
function of
ssGetInputPortWidth and ssGetGetOutputPortWidth.
• Function calls — In
ssSetCallSystemOutput, specify whichoutput elements
are performing function calls. See
matlabroot/simulink/src/
sfun_fcncall.c
for an example.
Thesample timesa respecifiedas pairs
[sample_time, offset_time] byusing
these macros:
ssSetSampleTime(S, sampleTimePairIndex, sample_time)
ssSetOffsetTime(S, offsetTimePairIndex, offset_time)
where sampleTimePairIndex starts at 0.
The valid sample time pairs are (upper-case values are macros defined in
simstruc.h):
[CONTINUOUS_SAMPLE_TIME, 0.0 ]
[CONTINUOUS_SAMPLE_TIME, FIXED_IN_MINOR_STEP_OFFSET]
[discrete_sample_period, offset ]
[VARIABLE_SAMPLE_TIME , 0.0 ]