Main Content

Simulink.op.ModelOperatingPoint

Complete information that represents model operating point in simulation

Since R2019a

Description

A 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 specified.

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.

Creation

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:

  1. On the Modeling tab, click Model Settings.

  2. In the Configuration Parameters dialog box, select Data Import/Export.

  3. Select Final states and Save final operating point.

By default, the Simulink.op.ModelOperatingPoint object is saved using a variable called 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.

Properties

expand all

Description of saved operating point, specified as a string or a character vector. The ModelOperatingPoint object has a default description that includes the name of the model and the simulation time at which the operating point was saved.

Example: Operating point of the model 'vdp' at simulation time 3.2137655751098118

Tips

The simulation time at which the model operating point was saved is also stored in the snapshotTime property.

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 valueFormat of loggedStates property value

Dataset

Simulink.SimulationData.Dataset object

  • Structure with time

  • Structure

  • Array

Structure that contains block states data

Tips

  • The loggedStates property 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 get and set functions.

  • Not all operating point information for built-in blocks is exposed in the loggedStates property for viewing or editing. For example, the loggedStates property does not include operating point information for:

    • Blocks inside For Each subsystems

    • Simscape™ blocks

    • Blocks inside referenced models that execute in accelerator mode

  • You cannot change the format for the data in the loggedStates property after a ModelOperatingPoint object is created.

This property is read-only.

Simulation time at which operating point was saved, returned as a double.

This property is read-only.

Start time of simulation that created operating point, returned as a double.

Object Functions

get Get operating point information for Stateflow chart, MATLAB System block, or S-function
setSet operating point information for Stateflow chart, MATLAB System block, or S-function

Examples

collapse all

Open the model sldemo_tonegen.

model = "sldemo_tonegen";
open_system(model);

Create a 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 finalOP.

simIn = setModelParameter(simIn,"StopTime","10",...
    "SaveFinalState","on","SaveOperatingPoint","on",...
    "FinalStateName","finalOP");

Simulate the model using the settings configured on the SimulationInput object.

out = sim(simIn);

Access the saved operating point, returned as part of the single Simulink.SimulationOutput object.

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


Create a 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");

Use the 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);

Tips

When you want to save an operating point from a simulation, disable Block reduction before simulating the model.

Version History

Introduced in R2019a

expand all