Main Content



Saves states data to the specified variable in the MATLAB® workspace.

Category: Data Import/Export


Default: Off, xout


Log states data to the MATLAB workspace.

Specify the name of the variable used to store the logged states data. See Save Block States and Simulation Operating Points for more information.


Do not log states data.


  • 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 a format other than Dataset, you can convert the logged data to Dataset format. Converting the data to Dataset makes it easier to post process with other logged data. For more information, see Dataset Conversion for Logged Data.

  • 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.

Programmatic Use

Parameter: SaveState
Value: 'on' | 'off'
Default: 'off'
Parameter: StateSaveName
Type: character vector
Default: 'xout'

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Related Topics