Main Content

States

Option to log block state values during simulation

Model Configuration Pane: Data Import/Export

Description

Specify whether the software logs block state values to the specified MATLAB® variable. Some blocks have hidden states data that is not captured by state logging.

By default, simulation results are returned as a single Simulink.SimulationOutput object. The logging variable you specify for logged states data becomes a property of the SimulationOutput object. To access the logged states data, use dot notation. For example, when you use the default output variable name out and the default states logging variable name xout, access the states data using this code.

xout = out.xout;

Settings

off (default) | on
off

The software does not log block states during simulation.

on

The software logs block state values during simulation. By default, the state data is saved using the variable name xout. To use a different variable name, specify a valid MATLAB variable name in the text box.

The variable must not have a name that matches the name of any object functions or properties of the Simulink.SimulationOutput object.

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

Tips

  • Specify the format for the logged states data using the Format parameter.

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

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

  • Dataset format does not support:

    • Logging states during rapid accelerator simulation

    • Logging states inside a function-call subsystem

    • Code generation

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

  • If you log states 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.

Recommended Settings

The table summarizes recommended values for this parameter based on considerations related to code generation.

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Programmatic Use

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

Version History

Introduced before R2006a