Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

mdlZeroCrossings - Update zero-crossing vector

Required

No

C Syntax

#define MDL_ZERO_CROSSINGS
void mdlZeroCrossings(SimStruct *S)

C 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. 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

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.

Example

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.

Languages

C, C++

See Also

mdlInitializeSizes, ssGetNonsampledZCs

  


Related Products & Applications

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