Use Operating Points to Specify Initial State of Simulation
This example shows how to use operating points to get the results of a continuous simulation without starting from time t = 0. An operating point is a snapshot of the state of a Simulink® model during simulation. If your model contains a Stateflow® chart, the operating point includes information about active states, output and local data, and persistent variables. For more information, see Save and Restore Operating Points for Stateflow Charts.
The sf_boiler
model illustrates the logic of a bang-bang control system
that regulates the temperature of a boiler.
This model simulates for 1400 seconds. During the initial phase of the simulation, the temperature of the boiler rises from 15℃ to 20℃. This initial phase of the simulation takes approximately 500 seconds.
To see how the system reacts to changes in the temperature set point after the initial phase of simulation, simulate the model and save the operating point at t =500. Then, load that operating point and run the simulation between t = 500 and t = 1400 using different temperature set points.
For more information about this model, see Model Bang-Bang Temperature Control System.
Save Operating Point for Initial Simulation Segment
Open the
sf_boiler
model.openExample("sf_boiler")
Set the model to save the final operating point. Open the Configuration Parameters dialog box and, in the Data Import/Export pane:
Select Final states and enter a name for the operating point. For this example, use
xFinal
.Select Save final operating point.
Click OK.
Set the stop time for this simulation segment. In the Simulation tab, set Stop Time to
500
.Run the simulation.
When you simulate the model, you save the operating point at t = 500 in the variable
xFinal
in the MATLAB® base workspace.In the Configuration Parameters dialog box, in the Data Import/Export pane, clear the Save final operating point and Final states parameters. This step prevents you from overwriting the operating point you saved in the previous step.
Start Simulation from Operation Point
Load the operating point as the initial state of the model. In the Configuration Parameters dialog box, in the Data Import/Export pane, select Initial state and enter the variable that contains the operating point of your chart,
xFinal
. Then, click OK.Define the stop time for the new simulation segment. In the Simulation tab, set Stop Time to
1400
.Run the simulation.
The model starts at t = 500 without repeating the initial phase of the simulation. The Scope block shows the chart output between t = 500 and t = 1400 using the original temperature set point of 20℃.
Change the value of the
temperature set point
block to18
.Run the simulation again.
The Scope block shows the chart output between t = 500 and t = 1400 using the modified temperature set point of 18℃.
See Also
Model Settings
- Initial state (Simulink) | Final states (Simulink) | Save final operating point (Simulink)
Objects
Stateflow.op.BlockOperatingPoint
|Stateflow.op.OperatingPointContainer
|Stateflow.op.OperatingPointData
Functions
setActive
|setPrevActiveChild
|clone
|get
(Simulink) |set
(Simulink)