Initial state
Option to specify initial model state or operating point for simulation
Model Configuration Pane: Data Import/Export
Description
When you load initial states, the simulation starts from the specified state or operating point. You specify the initial state or operating point as a variable or expression. At the start of simulation, the software loads the initial state data.
Settings
off
(default) | on
off
By default, the model does not load initial states or an initial operating point at the start of simulation. The simulation uses default initial states and initial conditions specified in the model.
on
The simulation starts from the specified initial state or operating point. In the text box, specify the name of the variable that contains the initial state or operating point. For example, the initial state could be a
Simulink.op.ModelOperatingPoint
object saved from a prior simulation of the same model.To specify the most complete initial state information, use a
ModelOperatingPoint
object. The model operating point contains complete information about the state of the simulation, 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.When you specify logged states data as the initial state for simulation, use the
Dataset
,Structure
, orStructure with time
format. These formats support several options that theArray
format does not support:Associating initial state values with the path to the block to which the state applies. This association removes dependencies on the block execution order.
Using different data types for each initial state value.
Initializing a subset of states.
Initializing states for a model hierarchy.
The
Array
format is not recommended. When you log states data using theArray
format, the order of the states within the array depends on the execution order, which can change from one simulation to the next. TheArray
format does not include block path information, so the order of states in the array determines the initial state value associated with each block.
Examples
Tips
Initial states loaded using the Initial state parameter override initial conditions and initial values specified in the model.
To load initial state data for a model that contains bus-valued states, use the
Dataset
format.By default, the software issues a warning when you specify initial states using the
Array
format. You can control this diagnostic behavior using the Initial state is array parameter.The Initial state parameter does not load initial state data from a data dictionary. When a model uses a data dictionary and you disable model access to the base workspace, the Initial State parameter still has access to resolve variables in the base workspace.
Recommended Settings
The table summarizes recommended values for this parameter based on considerations related to code generation.
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | No recommendation |
Safety precaution | No recommendation |
Programmatic Use
Parameter: LoadInitialState |
Value: 'on' | 'off' |
Default: 'off' |
Parameter: InitialState |
Type: string | character vector |
Value:
Simulink.op.ModelOperatingPoint object |
Simulink.SimulationData.Dataset object | structure |
matrix |
Default: 'xInitial' |