User`s guide

Overview of the C MEX S-Function Routines
3-39
To check for a sample hit during execution (in mdlOutputs or mdlUpdate), use
the
ssIsSampleHit or ssIsContinuousTask macro. For example, if your first
sample time is continuous, then you used the following code fragment to check
for a sample hit. Note that you would get incorrect results if you used
ssIsSampleHit(S,0,tid).
if (ssIsContinuousTask(S,tid)) {
}
If, for example, you wanted to determine if the third (discrete) task has a hit,
then you would use the following code-fragment:
if (ssIsSampleHit(S,2,tid) {
}
The synopsis is:
static void mdlInitializeSampleTimes(SimStruct *S)
{
} /* End of mdlInitializeSampleTimes. */
Example: mdlInitializeSampleTimes.
This example specifies that there are two
discrete sample times with periods of 0.01 and 0.5 seconds.
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, 0.01);
ssSetOffsetTime(S, 0, 0.0);
ssSetSampleTime(S, 1, 0.5);
ssSetOffsetTime(S, 1, 0.0);
} /* End of mdlInitializeSampleTimes. */
Port-based Sample Times
The next three section discuss how to specify port-based sample times. You
must s pecify information in
mdlInitializeSizes
mdlSetInputPortSampleTime
mdlSetOutputPortSampleTime