Writing S-Functions | ![]() ![]() |
Syntax
void mdlZeroCrossings(SimStruct *S)
Arguments
S
Simstruct representing an S-function block.
Description
An S-function needs to provide this optional method only if it does zero-crossing detection. This method should update the S-function's zero-crossing vector, using ssGetNonsampleZCs
.
You can use the optional 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:
mdlOutputs
Thus, the zero crossing signals are used to locate the discontinuities and end the current time step at the point of the zero crossing. To provide Simulink with zero crossing signal(s), mdlZeroCrossings
updates the ssGetNonsampleZCs(S)
vector.
Example
See matlabroot
/simulink/src/sfun_zc.c
.
Languages
See Also
mdlInitializeSizes, ssGetNonsampleZCs
![]() | mdlUpdate | SimStruct Functions | ![]() |