Initial state
Option to specify initial model state or operating point for simulation
Model Configuration Pane: Data Import/Export
Description
The Initial state parameter specifies whether the model loads initial states or an operating point at the start of simulation and the initial state or operating point from which to simulate.
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.
Array format is not recommended for specifying the initial state. By default, the software issues a warning if you specify the initial state as an array.
Because the
Array
format does not include block path information, the software pairs the state values in array with block states in the model based on:The order of the state values in the array
The execution order for the model
The execution order can change from one simulation to the next if you modify the model and from one release to the next even if you do not modify the model. If the order of the states in the array does not match the execution order as intended, the simulation can produce unexpected results.
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.
Loading an initial state or operating point that uses the
Dataset
format is not supported for rapid accelerator or deployed simulations if one or more states in the model has any of these data types:half
string
Character vector
Fixed-point
Loading an initial state or operating point that uses 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.
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" |