User`s guide

3 Writing S-Functions As C-MEX files
3-34
When inherited port based sample times are specified, the sample time will be
one of the following:
continuous:
[0.0, 0.0]
discrete: [period, offset] where 0.0 < period < inf and
0.0 <= offset < period
Constant, triggered, and variable step sample times will not be propagated to
S-functions with port based sample times.
This is the code synopsis for
mdlSetInputPortSampleTime:
#if defined(MDL_SET_INPUT_PORT_SAMPLE_TIME) && defined(MATLAB_MEX_FILE)
static void mdlSetInputPortSampleTime(SimStruct *S,
int_T portIdx,
real_T sampleTime,
real_T offsetTime)
{
}
#endif /* MDL_SET_INPUT_PORT_SAMPLE_TIME */
See matlabrooot/simulink/src/sfun_multirate.c for an example.
mdlSetOutputPortSampleTime
This routine is called with the ca ndidate sample time for an inherited sample
timeoutput port.Ifthe proposedsampletime is acceptable,theroutine setsthe
actual port sample time using
ssSetOutputPortSampleTime. If the sample
timeisunacceptableanerror isgeneratedby
ssSetErrorStatus. Notet hat any
otherinheritedinputoroutputportswhose sampletimesare implicitlydefined
by the sample time of the given port can also have their widths set by calls to
ssSetInputPortSampleTime or ssSetOutputPortSampleTime.
Normally, sample times are propagated forwards. However, if sources feeding
this block have an inherit ed sample time, then Simulink may c hoose to back-
propagate known sample times to this block. When back-propagating sample
times, Simulink calls this routine in succession for all inherited output port
signals.