Documentation Center

  • Trial Software
  • Product Updates

Contents

ssGetNonsampledZCs

Get the zero-crossing signal values

Syntax

real_T *ssGetNonsampledZCs(SimStruct *S)

Arguments

S

SimStruct representing 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++

Example

The following excerpt from matlabroot/simulink/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.csfun_zc_sat.c used in sfcndemo_sfun_zc_satsfcndemo_sfun_zc_sat for a complete example that uses this function.

Was this topic helpful?