| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
No
#define MDL_ZERO_CROSSINGS
void mdlZeroCrossings(SimStruct *S)
An S-function needs to provide this optional method only if it does zero-crossing detection. Implementing zero-crossing detection typically requires using the zero-crossing and mode work vectors to determine when a zero crossing occurs and how the S-function's outputs should respond to this event. The mdlZeroCrossings method should update the S-function's zero-crossing vector, using ssGetNonsampledZCs.
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 the Simulink engine with signals that are to be tracked for zero crossings. These are typically
Continuous signals entering the S-function
Internally generated signals that cross zero when a discontinuity would normally occur in 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 the engine with zero-crossing signals, mdlZeroCrossings updates the ssGetNonsampleZCs(S) vector.
For an example, see matlabroot/simulink/src/sfun_zc_sat.c. A detailed description of this example can be found in Zero Crossings in the "Writing S-Functions" documentation.
C, C++
mdlInitializeSizes, ssGetNonsampledZCs
![]() | mdlUpdate | SimStruct Functions Reference | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |