Documentation

Simulink.BlockDiagram.getInitialState

Return initial state data of block diagram

Syntax

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

Description

x0 = Simulink.BlockDiagram.getInitialState('model') returns the initial state data of the block diagram specified by the input argument model. You can use this initial state data as the initial state for simulating a model or to provide an initial state condition to the linearization commands. To specify the initial state for a simulation, use the LoadInitialState model argument or the Data Import/Export > Initial state configuration parameter.

To specify the format for the initial state data, use the SaveFormat model argument. The default format is 'Dataset'. Other formats 'Array', 'Structure', and 'StructureWithTime'. Alternatively, you can set the initial state format using the Data Import/Export > Format configuration parameter.

  • If format is 'Dataset', then the Simulink.BlockDiagram.getInitialState function returns a Simulink.SimulationData.Dataset object.

  • For other format settings, the function returns 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 is shown for S-function blocks.

      The name of the discrete state is 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 this function to return the initial state data simplifies specifying initial state values for models with multiple states. Each state is associated with the full path to its parent block.

Introduced in R2006b

Was this topic helpful?