Main Content

ssGetNonsampledZCs

Get the zero-crossing signal values

Syntax

real_T *ssGetNonsampledZCs(SimStruct *S)

Arguments

S

SimStruct that represents an S-Function block.

Returns

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

Description

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

Languages

C, C++

Examples

The following excerpt from matlabroot/toolbox/simulink/sfuntemplates/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.

Version History

Introduced before R2006a