User`s guide

3 Writing S-Functions As C-MEX files
3-40
Specifying the Number of Sample Times in mdlInitializeSizes. To specify port-based
sample times, use
ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES)
with:
ssSetInputPortSampleTime(S, idx, period)
ssSetInputPortOffsetTime(S, idx, offset)
ssSetOutputPortSampleTime(S, idx, period)
ssSetOutputPortOffsetTime(S, idx, offset)
The inputPortIndex and outputPortIndex range from 0 to the number of
input (output) ports minus 1.
When you specify port based sample times, Simulink will call
mdlSetInputPortSampleTime andmdlSetOutputPortSampleTime to determine
the rates of inherited signals. Once all rates have been determined completed,
Simulink will also call
mdlInitializeSampleTimes to configure function-call
connections.If yourS-function doesnot have anyfunction-call connections this
routine should be empty.
Note mdlInitializeSizes should not contain any ssSetSampleTime or
ssSetOffsetTime calls when using port-based sample times.
mdlSetInputPortSampleTime. Simulink calls this routine with the candidate
sample time for an inherited sample time input port. If the proposed sample
time is acceptable, the routine sets the actual port sample time using
ssSetInputPortSampleTime. If the sample time is unacceptable
ssSetErrorStatus generates an error. If any other inherited i nput or output
ports have sa mple times that are implicitly defi ned by the sample time of the
given port, then you can specify their widths by calls to
ssSetInputPortSampleTime or ssSetOutputPortSampleTime.
When you specify port based sample times as inherited, 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