Complete information that represents model operating point in simulation
Simulink.op.ModelOperatingPoint object contains a complete
representation of a model operating point that you can use to specify the initial state for a
simulation. For example, when you run a set of simulations for a model of a system that has a
startup phase or initialization behavior, you can simulate the model through the end of the
startup or initialization phase once, save the model operating point, then run a set of
simulations that use the operating point as the initial state. If you do not modify the model,
simulating a model using a
Simulink.op.ModelOperatingPoint object as the
initial state produces the same results as a simulation with no initial state
The operating point for a model represents the model state in simulation, including logged block states, hidden block states, the state of the solver and execution engine, and output values for some blocks. For more information, see Use Model Operating Point for Faster Simulation Workflow.
A model configured to save the final operating point creates a
Simulink.op.ModelOperatingPoint object when the simulation completes or
when you pause or stop the simulation. To configure a model to save the final operating point:
By default, the
Simulink.op.ModelOperatingPoint object is saved using a
xFinal. To save the operating point using a different
variable name, specify the variable name you want to use in the Final
states text box.
When you return simulation results using a single simulation output, the
Simulink.op.ModelOperatingPoint object is returned as part of the
Simulink.SimulationOutput object that contains all the simulation data.
description — Description of saved operating point
string | character vector
Description of saved operating point, specified as a string or a character vector.
ModelOperatingPoint object has a default description that includes
the name of the model and the simulation time at which the operating point was
Operating point of the model 'vdp' at simulation time
The simulation time at which the model operating point was saved is also stored in
loggedStates — Operating point information for built-in blocks
Simulink.SimulationData.Dataset object | structure
Operating point information for built-in blocks, specified as a
Simulink.SimulationData.Dataset object or a structure.
The format of the data in the
loggedStates property for a
ModelOperatingPoint object created from simulation depends on the
format used for logging states and output data. To configure the format for logging
states and outputs, use the Configuration Parameters dialog box. On the
Modeling tab, click Model Settings. Then, on
the Data Import/Export pane, select a value for the Format parameter.
|Format parameter value||Format of |
Structure that contains block states data
loggedStatesproperty contains the operating point information for built-in blocks and S-functions that do not implement custom operating point behavior. To access or modify the operating point information for a Stateflow® chart, a MATLAB System block, or an S-function with a custom operating point implementation, use the
Not all operating point information for built-in blocks is exposed in the
loggedStatesproperty for viewing or editing. For example, the
loggedStatesproperty does not include operating point information for:
Blocks inside For Each subsystems
Blocks inside referenced models that execute in accelerator mode
You cannot change the format for the data in the
loggedStatesproperty after a
ModelOperatingPointobject is created.
snapshotTime — Simulation time at which operating point was saved
This property is read-only.
Simulation time at which operating point was saved, returned as a double.
startTime — Start time of simulation that created operating point
This property is read-only.
Start time of simulation that created operating point, returned as a double.
Save and Restore Model Operating Point
Open the model
model = "sldemo_tonegen"; open_system(model);
Simulink.SimulationInput object to specify parameter values to use in simulation.
simIn = Simulink.SimulationInput(model);
Configure the simulation to stop after ten seconds and save the final operating point in a variable named
simIn = setModelParameter(simIn,"StopTime","10",... "SaveFinalState","on","SaveOperatingPoint","on",... "FinalStateName","finalOP");
Simulate the model using the settings configured on the
out = sim(simIn);
Access the saved operating point, returned as part of the single
finalOP = out.finalOP
finalOP = Simulink.op.ModelOperatingPoint Operating point of the model 'sldemo_tonegen' at simulation time 10. Properties loggedStates description startTime (Read-only) snapshotTime (Read-only) Methods get set
SimulationInput object to configure another simulation that uses the operating point saved from the first simulation.
simIn2 = Simulink.SimulationInput(model);
Configure the model to simulate to a stop time of twenty seconds.
simIn2 = setModelParameter(simIn2,"StopTime","20");
setInitialState function to specify the initial state for the simulation using the
Simulink.op.ModelOperatingPoint object saved from the first simulation.
simIn2 = setInitialState(simIn2,finalOP);
Simulate the model from the initial operating point.
out2 = sim(simIn2);
When you want to save an operating point from a simulation, disable Block reduction before simulating the model.
Introduced in R2019a