Get the zero-crossing signal values
real_T *ssGetNonsampledZCs(SimStruct *S)
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
illustrates usage of this macro to update the
zero-crossing array in the matlabroot
/toolbox/simulink/simdemos/simfeatures/src/sfun_zc.cmdlZeroCrossings
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.