Main Content

Final states

Option to log final state values

Model Configuration Pane: Data Import/Export

Description

Specify whether to log the final values of block states in the model at the end of simulation using the specified variable name. You can use the final states data as the initial state for another simulation.

When you want to use final states data as the initial state for another simulation, consider selecting Save final operating point. The model operating point contains complete information about the simulation state, including block states, hidden block states, the state of the solver and execution engine, and output values for some blocks. When you use a model operating point as the initial state, the simulation results are the same as a simulation that runs from the beginning. When you specify initial states using logged states data alone, the simulation results might not match. For more information, see Specify Initial State for Simulation.

Settings

off (default) | on
off

The software does not save final state values at the end of simulation.

on

At the end of the simulation, the software saves the final state values. By default, the final state values are stored in the variable xFinal. To use a different variable name for final states data, specify a valid MATLAB® variable name in the text box.

Tips

  • The final states data has the format you specify using the Format parameter.

  • The final states data is empty when the model does not contain any states or contains only hidden states.

  • To use final state data as the initial state for another simulation, set the Format parameter to Dataset if your model contains bus-valued states.

  • Logging final states using the Dataset format is not supported in rapid accelerator or deployed simulations if one or more states in the model have any of these data types:

    • half

    • string

    • Character vector

    • Fixed-point

  • Logging final states using the Dataset format is not supported if a referenced model that simulates in a mode other than normal contains one or more states that have any of these data types:

    • half

    • string

    • Character vector

    • Fixed-point

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: SaveFinalState
Value: 'on' | 'off'
Default: 'off'
Parameter: FinalStateName
Type: string | character vector
Value: valid MATLAB variable name
Default: 'xFinal'

Version History

Introduced before R2006a