Hauptinhalt

States

R2026b

Option to log block state values during simulation

Model Configuration Pane: Data Import/Export

Description

The States parameter specifies whether the simulation logs block state values. Some blocks have hidden states that are not logged when you enable this parameter.

By default, the data logs to a property of the Simulink.SimulationOutput object with the name xout. To access the logged state data, use dot notation. For example, when you use the default output variable name out and the default state-logging variable name xout, access the state data using this command.

xout = out.xout;

Settings

off (default) | on
off

The simulation does not log block states during simulation.

on

The simulation logs block state values during simulation.

By default, the property of the Simulink.SimulationOutput object that contains the logged state data has the name xout. To log data to a property with a different name, enter the name in the box. The name must be a valid MATLAB® variable name and must not match the name of any object functions or properties of the Simulink.SimulationOutput object. For more information, see Variable Names.

For more information about state data, see Save Block States and Simulation Operating Points.

Tips

  • The state-logging variable is empty when you enable state logging for a model that has no states.

  • Specify the format for the logged state data using the Save format parameter.

  • To log fixed-point state data, log state data using the Dataset format.

  • Dataset format does not support:

    • Logging states during rapid accelerator simulations

    • Logging states inside function-call subsystems

    • Logging states in simulations deployed using Simulink® Compiler™

    • Code generation

  • When you log state data using the Dataset format, state data streams to the Simulation Data Inspector during simulation.

  • If you log state data in Structure with time format or in Array format while also logging time, select the Record logged workspace data in Simulation Data Inspector parameter to view the data in the Simulation Data Inspector after simulation.

  • For information about logging model operating points during simulation, see Save Model Operating Point During Simulation.

Programmatic Use

Parameter: SaveState
Type: string | character vector
Value: "on" | "off"
Default: 'off'
Parameter: StateSaveName
Type: string | character vector
Value: valid MATLAB variable name
Default: 'xout'

Version History

Introduced before R2006a