In R2019a, the
SimState object was renamed to
To effectively design a system, you simulate a model iteratively, so you can analyze the system based on different inputs, boundary conditions, or operating conditions. In many applications, when performing multiple simulations, a startup phase with significant dynamic behavior is common. For example, the cold start takeoff of a gas turbine engine occurs before each set of aircraft maneuvers. In multiple simulations, you ideally:
Simulate the startup phase once.
Save the simulation snapshot at the end of the startup phase.
Use this snapshot as the initial state for each set of conditions or maneuvers.
ModelOperatingPoint object to save the snapshot of a
simulation. Once you save the snapshot, in future simulations, restore the
ModelOperatingPoint object and use it to set initial conditions.
ModelOperatingPoint object contains information about:
State of the solver and execution engine
Zero-crossing signals for blocks that register zero crossings
Output values of certain blocks in the model
Simulink® analyzes block connections and other information to determine whether it is using the output values effectively as state information.
ModelOperatingPoint object also stores the hidden states
of these blocks:
Variable Transport Delay
For Each subsystem
Conditionally executed subsystems
Simscape™ Multibody™ Second Generation
By storing this information, the
ensures that the result of a simulation that starts from the operating point is the same as a
simulation that runs from the beginning.
ModelOperatingPoint object saves the snapshot of a
simulation, it saves information in addition to the logged states in the model. Restore
all of this information to ensure that the simulation matches the uninterrupted
simulation. For example, if solver information affected the simulation, then changing
the state of a block without using
ModelOperatingPoint can produce
You can save several operating points during a simulation, then resume the simulation from any of those operating points.
ModelOperatingPoint object restores the state of blocks that
are typically difficult to restore to a particular state, for example, the Transport
delay block. The state of the Transport Delay block is not saved in the
structure format or the array format when you log data using the Final
states configuration parameter. With dataset logging format, the answers
ModelOperatingPoint always match those returned by state
logging (non-Operating Point save). Logged states for blocks inside of accelerator-mode
model reference are visible and editable. Logged states for many blocks with custom
operating point functions, for example, Simscape, model reference accel and variable
transport delay are editable.
You can also use the Final states option in the Configuration Parameters Data Import/Export pane to save a simulation state. However, this option saves only logged states—the continuous and discrete states of blocks. These states are only subsets of the complete simulation state of the model. They do not include information about hidden states of blocks, which required for the proper execution of a block.
Save an operating point at the beginning of the final step using one of these options:
At the final Stop time.
When you interrupt a simulation with the Pause or
Stop button. You can also save an operating point when you
pause a simulation using
When you use
set_param or a block, like the Stop
block, to stop a simulation.
In the Configuration Parameters dialog box, in the Data Import/Export pane, select the Final states check box. The Save final Operating Point check box becomes available.
Select the Save final Operating Point check box.
In the Final states text box, enter a variable name for
Simulate the model.
sim command with
set_param. Set the
SaveOperatingPoint parameter to
sldemo_tonegen set_param('sldemo_tonegen','SaveFinalState','on','FinalStateName',... 'myOperPoint','SaveOperatingPoint','on'); simOut = sim('sldemo_tonegen','StopTime','10'); myOperPoint = simOut.myOperPoint;
To configure the simulation to restore the operating point that you saved, use
LoadInitialState. Simulink® restores the
ModelOperatingPoint object when you simulate the model.
set_param('sldemo_tonegen','LoadInitialState','on','InitialState',... 'myOperPoint'); myOperPoint = simOut.myOperPoint;
Before you save the operating point, disable the Block Reduction parameter in Configuration Settings > Simulation Target > Advanced Parameters.
Restore the simulation snapshot using the
after modifying the model. The Start time does not change from
the value in the simulation that generated the operating point. It is a reference value for
all time and time-dependent variables in both the original and the current simulation. For
example, a block can save and restore the number of sample time hits that occurred since the
beginning of simulation as its
Consider a model that you ran from 0 to100 s and that you now want to run from 100 to 200 s. The Start time is 0 s for both the original simulation and for the current simulation. The initial time of the current simulation is 100 s. Also, if the block had 10 sample time hits during the original simulation, Simulink recognizes that the next sample time hit is the 11th, relative to 0, not 100 s.
If you change the Start time before restoring the
ModelOperatingPoint, Simulink overwrites the Start time with the value saved
In the Configuration Parameters dialog box, in the Data Import/Export pane, under Load from workspace, select the Initial state check box. The text box becomes available.
Enter the name of the variable containing the
ModelOperatingPoint in the text box.
Set the Stop time to a value greater than the time at which the operating point was saved.
You can use
ModelOperatingPoint objects saved in releases starting
with R2010a to restore the
ModelOperatingPoint of a model. However,
this option restores only the logged states of the model. To see the version of
Simulink used to save the
ModelOperatingPoint, examine the
version parameter of the
Simulink detects if the
ModelOperatingPoint object you provided as
the initial state was saved in the current release. By default, Simulink displays an error message if the
not saved in the current release. You can configure the diagnostic to allow Simulink to display the message as a warning and try to restore as many of the values
as possible. To enable this best-effort restoration, in the Configuration Parameters
dialog box set the message for Operating Point object from earlier
warning. Previously named
SimState objects are loaded as
objects in 19a.