Main Content

Final states


Saves the logged states of the model at the end of a simulation to the specified MATLAB® variable.

Category: Data Import/Export


Default: Off, xFinal


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

Specify the name of the MATLAB variable in which to store the values of these final states. See Importing and Exporting States for more information.


Simulink software does not export the final state data during simulation.


  • You must select the Final states check box before entering the final states variable.

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

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

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

    • You enable Final states.

    • A model has no states.

  • Using the Final states is not always sufficient for complete and accurate restoration of a simulation state. The ModelOperatingPoint object contains the set of all variables that are related to the simulation of a model. For details, see Save complete SimState in final state and Use Model Operating Point for Faster Simulation Workflow.

  • See Save Block States and Simulation Operating Points for more information.

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

Programmatic Use

Parameter: SaveFinalState
Value: 'on' | 'off'
Default: 'off'
Parameter: FinalStateName
Type: character vector
Default: 'xFinal'

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Related Topics