Main Content

Best Practices for Saving the Operating Point of a Chart

An operating point is a snapshot of the state of a Simulink® model at a specific time during simulation. For a Stateflow® chart, an operating point includes:

  • Activity of chart states

  • Values of chart local data

  • Values of chart output data

  • Values of persistent data in MATLAB® functions and Truth Table blocks

For more information, see Using Operating Points in Stateflow.

Use MAT-Files to Save a Operating Point for Future Use

To save an operating point from the MATLAB base workspace, save the variable with final state data in a MAT-file.

For example, type at the command prompt:


For more information, see save in the MATLAB documentation.

Use Scripts to Save Operating Point Commands for Future Use

To save a list of operating point commands for future use, copy them from a procedure and paste them in a MATLAB script.

For example, to reuse the commands in Divide a Long Simulation into Segments, you can store them in a script named sf_boiler_operatingpoint_commands.m:

% Open the model.

% Set parameters to save the operating point at the desired time.
set_param("sf_boiler", ...
    SaveFinalState="on", ...
    FinalStateName="sf_boiler_ctx01", ...

% Specify the start and stop times for the simulation segment.
set_param("sf_boiler", ...
    StartTime="0", ...

% Simulate the model.

% Disable saving of the operating point to avoid overwriting.
set_param("sf_boiler", ...
    SaveOperatingPoint="off", ...

% Load the operating point.
set_param("sf_boiler", ...
    LoadInitialState="on", ...

% Specify the new stop time for the simulation segment.

% Simulate the model.

The start time does not change, but the operating point restore fast forwards the simulation to the time of the snapshot.

Related Topics