User`s guide

Overview of the C MEX S-Function Routines
3-41
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 candidate sample
time for an inherited sample time output port. If the proposed sample time is
acceptable, the routine sets the actual port sample time usi ng
ssSetOutputPortSampleTime. If the sample time is unacceptable an error is
generated b y
ssSetErrorStatus. Any other inherited input or output ports
whose sample times are implicitly defined 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 s ources feeding
this block have an inherited sample time, then Simulink may choose to back-
propagate known sample times to this block. When back-propagating sample
times, Simulink calls this routine in succession for a ll inherited output port
signals.
This is the code synopsis for
mdSetOutputPortSampleTime:
#if defined(MDL_SET_OUTPUT_PORT_SAMPLE_TIME) && defined(MATLAB_MEX_FILE)
static void mdlSetOutputPortSampleTime(SimStruct *S,
int_T portIdx,
real_T sampleTime,
real_T offsetTime)
{
}
#endif /* MDL_SET_OUTPUT_PORT_SAMPLE_TIME */
See matlabrooot/simulink/src/sfun_multirate.c for an example.