This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Get a block's discrete states


real_T *ssGetDiscStates(SimStruct *S)



SimStruct representing an S-Function block.


A pointer (real_T *) to the discrete state vector as an array of length ssGetNumDiscStates(S). Returns NULL if the S-function does not have any discrete states.


Use to obtain the block's discrete states. Typically, the state vector is initialized in mdlInitializeConditions, updated in mdlUpdate, and used in mdlOutputs. You can use this macro in the simulation loop, mdlInitializeConditions, or mdlStart routines.


C, C++


See the S-function dsfunc.c used in sfcndemo_dsfunc for an example on how to initialize and update the discrete state vector.

Introduced before R2006a