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:

save('sf_car_ctx01.mat', 'sf_car_ctx01')

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.
sf_boiler;

% Set parameters to save the operating point at the desired time.
set_param('sf_boiler','SaveFinalState','on','FinalStateName',...
'sf_boiler_ctx01','SaveOperatingPoint','on');

% Specify the start and stop times for the simulation segment.
set_param('sf_boiler','StartTime','0','StopTime','400');

% Simulate the model.
sim('sf_boiler');

% Disable saving of the operating point to avoid overwriting.
set_param('sf_boiler','SaveOperatingPoint','off', ...
'SaveFinalState','off');

% Load the operating point.
set_param('sf_boiler', 'LoadInitialState', 'on', ...
'InitialState', 'sf_boiler_ctx01');

% Specify the new stop time for the simulation segment.
set_param('sf_boiler','StopTime','600');

% Simulate the model.
sim('sf_boiler');

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

Related Topics