Saves state data to the specified MATLAB® variable during a simulation.

Category: Data Import/Export


Default: Off, xout


Simulink® software exports state data to the MATLAB workspace during simulation.

Specify the name of the MATLAB variable used to store state data. See Importing and Exporting States for more information.


Simulink does not export state data during simulation.


  • Simulink saves the states in a MATLAB workspace variable having the specified name.

  • The saved data has the format that you specify with the Format parameter.

  • If you select the States check box, Simulink logs fixed-point states only if you set the Format parameter to Dataset.

  • Dataset format does not support:

    • Logging states information inside a function-call subsystem

    • Code generation

  • Simulink creates empty variables for state logging (xout) if both of these conditions apply:

    • You enable States.

    • A model has no states.

  • To specify an interval for logging, use the Logging intervals parameter.

  • If you use a format other than Dataset, you can convert the logged data to Dataset format. Converting the data to Dataset makes it easier to postprocess with other logged data. For more information, see Dataset Conversion for Logged Data.

  • To log States data to the Simulation Data Inspector, check the Record logged workspace data in Simulation Data Inspector parameter.

Command-Line Information

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

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Related Topics