This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Get the zero-crossing signal values


real_T *ssGetNonsampledZCs(SimStruct *S)



SimStruct representing an S-Function block.


A pointer (real_T *) to the zero-crossing signal values.


Use to obtain a pointer to the vector containing the current values of the signals that the variable-step solver monitors for zero crossings. The variable-step solver tracks the signs of these signals to bracket points where they cross zero. The solver then takes simulation time steps at the points where the zero crossings occur. This vector has length ssGetNumNonsampledZCs(S).


C, C++


The following excerpt from matlabroot/toolbox/simulink/simdemos/simfeatures/src/sfun_zc.c illustrates usage of this macro to update the zero-crossing array in the mdlZeroCrossings callback function.

static void mdlZeroCrossings(SimStruct *S)
      int_T i;
      real_T *zcSignals = ssGetNonsampledZCs(S);
      InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
      int_T nZCSignals = ssGetNumNonsampledZCs(S);

      for (i = 0; i < nZCSignals; i++) {
          zcSignals[i] = *uPtrs[i];

See the S-function sfun_zc_sat.c used in sfcndemo_sfun_zc_sat for a complete example that uses this function.

Introduced before R2006a

Was this topic helpful?