User`s guide
3 Writing S-Functions As C-MEX files
3-52
last call to this routine. The memory allocated to the derivative vector changes
during execution.
The synopsis is:
#define MDL_DERIVATIVES /* Change to #undef to remove function. */
#if defined(MDL_DERIVATIVES)
static void mdlDerivatives(SimStruct *S)
{
}
#endif /* MDL_DERIVATIVES */
For an example, see matlabroot/simulink/src/csfunc.c.
mdlZeroCrossings
You canuse theoptional mdlZeroCrossings routine, when your S-function has
registered the
CONTINUOUS_SAMPLE_TIME and has nonsampled zero crossings
(
ssGetNumNonsampledZCs(S) > 0). The mdlZeroCrossings routine is used to
provide Simulink with signals that are to be tracked for zero crossings. These
are typically:
• Continuous signals entering the S-function
• Internally generated s ignals that cross zero when a discontinuity would
normally occur in
mdlOutputs
Thus, the zero crossing signals are used to locate the discontinuities a nd end
thecurrenttimestepatthepointofthezero crossing.ToprovideSimulinkw ith
zero crossing signal(s),
mdlZeroCrossings updatest hessGetNonsampleZCs(S)
vector.
The synopsis is:
#define MDL_ZERO_CROSSINGS /* Change to #undef to remove function. */
#if defined(MDL_ZERO_CROSSINGS) && (defined(MATLAB_MEX_FILE) || defined(NRT))
static void mdlZeroCrossings(SimStruct *S)
{
}
#endif /* MDL_ZERO_CROSSINGS */
For an example, see matlabroot/simulink/src/sfun_zc.c.