Main Content


Get the mode vector


int_T *ssGetModeVector(SimStruct *S)



SimStruct that represents an S-Function block.


A pointer (int_T *) to the mode vector.


Use to obtain a pointer to the mode vector. This vector has length ssGetNumModes(S). Typically, this vector is initialized in mdlInitializeConditions if the default value of 0 isn't acceptable. The mode vector is then used in mdlOutputs along with nonsampled zero crossings to determine when the output function should change mode.

For example, consider an absolute value function, which has two modes. When the input is zero or positive, the output method passes the input to the output. When the input is negative, the output method negates the input value. Which mode is used to produce the output value depends on the input value.

When you write an output function for a block with modes, write the code so that the block changes mode only when allowed. Use the ssIsModeUpdateTimeStep function to determine when you can change the mode.

Use the mode vector in the mdlZeroCrossings routine to determine the current mode.


C, C++


See the S-function sfun_zc.c used in sfcndemo_sfun_zc.

Version History

Introduced before R2006a