Return initial state structure of block diagram


x0 = Simulink.BlockDiagram.getInitialState('model')


x0 = Simulink.BlockDiagram.getInitialState('model') returns the initial state structure of the block diagram specified by the input argument model. This state structure can be used to specify the initial state vector in the Configuration Parameters dialog box or to provide an initial state condition to the linearization commands.

The command returns x0, a structure of the form

time: 0
signals: [1xn struct]

where n is the number of states contained in the model, including any models referenced by Model blocks. The signals field is a structure of the form

values: [1xm double]
dimensions: [1x1 double]
label: [char array]
blockName: [char array]
inReferencedModel: [bool]
sampleTime: [1x2 double]

  • values — Numeric array of length m, where m is the number of states in the signal

  • dimensions — Length of the values vector

  • label — Indication of whether the state is continuous (CSTATE) or discrete. If the state is discrete:

    The name of the discrete state will be shown for S-function blocks

    The name of the discrete state will be shown for those built-in blocks that assign their own names to discrete states

    DSTATE is used in all other cases

  • blockName — Full path to block associated with this state

  • inReferencedModel — Indication of whether the state originates in a model referenced by a Model block (1) or in the top model (0)

  • sampleTime — Array containing the sample time and offset of the block that owns the state

Using the state structure simplifies specifying initial state values for models with multiple states, as each state is associated with the full path to its parent block.

See Also

Introduced in R2006b

Was this topic helpful?