Main Content

ssGetModeVector

Get mode vector

Syntax

int_T *ssGetModeVector(SimStruct *S)

Arguments

S

SimStruct that represents an S-Function block.

Returns

A pointer (int_T *) to the mode vector.

Description

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 is not 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. The mode 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.

Languages

C, C++

Examples

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

Version History

Introduced before R2006a