Writing S-Functions    
mdlInitializeConditions

Initialize the state vectors of this S-function.

Syntax

Arguments

S
   SimStruct representing an S-Function block.

Description

Simulink invokes this optional method at the beginning of a simulation. It should initialize the continuous and discrete states, if any, of this S-Function block. Use ssGetContStates and/or ssGetDiscStates to get the states. This method can also perform any other initialization activities that this S-function requires.

If this S-function resides in an enabled subsystem configured to reset states, Simulink also calls this method when the enabled subsystem restarts execution. This method can use ssIsFirstInitCond macro to determine whether it is being called for the first time.

Example

This example is an S-function with both continuous and discrete states. It initializes both sets of states to 1.0:

For another example that initializes only the continuous states, see matlabroot/simulink/src/resetint.c.

Languages

C

See Also

mdlStart, ssIsFirstInitCond, ssGetContStates, ssGetDiscStates


  mdlGetTimeOfNextVarHit mdlInitializeSampleTimes