Main Content

get

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

Description

example

op = get(modelOP,blockPath) returns the operating point information op for the model element at the specified path blockPath. Use the get function to access operating point information for:

  • Stateflow® charts

  • MATLAB System blocks

  • S-functions with custom operating point implementation

To access the state for a built-in block, use the loggedStates property of the Simulink.op.ModelOperatingPoint object.

Examples

collapse all

Open the model sldemo_fuelsys.

mdl = "sldemo_fuelsys";
open_system(mdl)

Create a Simulink.SimulationInput object to configure a simulation of the model.

simIn = Simulink.SimulationInput(mdl);

Use the setModelParameter function to set the stop time for the simulation to 10 seconds and to configure the model to save the final states and operating point in the simulation.

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

Simulate the model using the simulation configuration stored on the SimulationInput object.

out = sim(simIn);

Get the Simulink.op.ModelOperatingPoint object that contains the model operating point.

modelOP = out.xFinal
modelOP = 
    Simulink.op.ModelOperatingPoint

    Operating point of the model 'sldemo_fuelsys' at simulation time 10.

  Properties

    loggedStates
    description
    startTime (Read-only)
    snapshotTime (Read-only)

  Methods

    get
    set


Get the operating point for the Stateflow™ chart named control_logic inside the subsystem named fuel_rate_control.

chartPath = mdl + "/fuel_rate_control" + "/control_logic";
chartOP = get(modelOP,chartPath)
chartOP = 
Block: "control_logic"    (handle)    (active)
  Path:     sldemo_fuelsys/fuel_rate_control/control_logic

  Contains:

    + Fail                 "State (AND)"               (active)            
    + Fueling_Mode         "State (AND)"               (active)            
    + O2                   "State (AND)"               (active)            
    + Pressure             "State (AND)"               (active)            
    + Speed                "State (AND)"               (active)            
    + Throttle             "State (AND)"               (active)            
      es_o                 "Block output data"         EngSensors [1, 1]   
      fuel_mode            "Block output data"         sld_FuelModes [1, 1]
      O2_normal            "State output data"         boolean [1, 1]      

Input Arguments

collapse all

Model operating point, specified as a Simulink.op.ModelOperatingPoint object.

Path to model element whose operating point you want to access, specified as a string or a character vector.

You cannot access or modify operating point information for Stateflow charts, MATLAB System blocks, or S-functions inside referenced models simulated using accelerator mode.

Output Arguments

collapse all

Element operating point, returned as a Stateflow.op.BlockOperatingPoint (Stateflow) object, an S-function operating point, or a MATLAB System block operating point.

Tips

Version History

Introduced in R2019a

expand all