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.


Initialize the state vectors of this C MEX S-function




C, C++


#define MDL_START
void mdlStart(SimStruct *S)



SimStruct representing an S-Function block.


The Simulink® engine invokes this optional method at the beginning of a simulation. The method performs initialization activities that this S-function requires only once, such as setting up user data or initializing states.

This method is called at the start of every successive simulation in Fast Restart mode, and it performs tasks that are required for every run. In contrast, mdlSetupRuntimeResources performs tasks once in Fast Restart mode and the results of those tasks done are reused by successive simulations.

If your S-function resides in an enabled subsystem and needs to reinitialize its states every whenever the subsystem is enabled, use mdlInitializeConditions to initialize the state values, instead of mdlStart.

In C MEX S-functions, use ssGetContStates and/or ssGetDiscStates to get the states.


See sfun_directlook.c for an example of how to use this function.

Introduced before R2006a