mdlGetSimState - Return the S-function simulation state as a valid MATLAB data structure, such as a matrix structure or a cell array.
Required
No
C Syntax
#define MDL_SIM_STATE
mxArray* mdlSetSimState(SimStruct* S)
C Arguments
- S
SimStruct representing an S-Function block.
M Syntax
GetSimState(s)
M Arguments
- s
Instance of Simulink.MSFcnRunTimeBlock class
representing the Level-2 M-File S-Function block.
Description
The Simulink engine invokes this custom method to get the
simulation state (SimState) of the model containing S.
A call to this method should occur after mdlStart and
before mdlTerminate to ensure that all of the S-function
data structures (e.g., states, DWork vectors, and outputs) are available.
C Example
% Function: mdlGetSimState
% Abstract:
% Package the RunTimeData structure as a MATLAB structure
% and return it.
%
static mxArray* mdlGetSimState(SimStruct* S)
{
int n = ssGetInputPortWidth(S, 0);
RunTimeData_T* rtd =
(RunTimeData_T*)ssGetPWorkValue(S, 0);
/* Create a MATLAB structure to hold the run-time data */
mxArray* simSnap =
mxCreateStructMatrix(1, 1, nFields, fieldNames);
return simSnap;
}Languages
C, C++, M
See Also
mdlSetSimState
 | mdlEnable | | mdlGetTimeOfNextVarHit |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit