Divide a Long Simulation into Segments

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.

Goal of the Tutorial

Suppose that you want to simulate the sf_boiler model without starting from t = 0.

This model simulates for 1400 seconds, but the output that interests you occurs sometime between t = 400 and 600. You can simulate the model, save the operating point at time t = 400, and then load that operating point for simulation between t = 400 and 600.

StepTaskReference
1Define the operating point for your chart.Define the Operating Point
2Load the operating point for your chart.Load the Operating Point
3Simulate the specific segment.Simulate the Specific Segment

Define the Operating Point

  1. Open the sf_boiler model.

  2. Enable saving of an operating point.

    1. Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Select the Final states check box.

    3. Enter a name, such as sf_boiler_ctx01.

    4. Select the Save final operating point check box.

    5. Click Apply.

     Programmatic equivalent

  3. Define the start and stop times for this simulation segment.

    1. In the Model Configuration Parameters dialog box, go to the Solver pane.

    2. For Start time, enter 0.

    3. For Stop time, enter 400.

    4. Click OK.

     Programmatic equivalent

  4. Start simulation.

    When you simulate the model, you save the complete operating point at t = 400 in the variable sf_boiler_ctx01 in the MATLAB base workspace.

  5. Disable saving of an operating point.

    This step prevents you from overwriting the operating point you saved in the previous step.

    1. Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Clear the Save final operating point check box.

    3. Clear the Final states check box.

    4. Click OK.

     Programmatic equivalent

Load the Operating Point

  1. Enable loading of an operating point.

    1. Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Select the Initial state check box.

    3. Enter the variable that contains the operating point of your chart: sf_boiler_ctx01.

    4. Click Apply.

     Programmatic equivalent

  2. Define the new stop time for this simulation segment.

    1. In the Model Configuration Parameters dialog box, go to the Solver pane.

    2. For Stop time, enter 600.

    3. Click OK.

    You do not need to enter a new start time because the simulation continues from where it left off.

     Programmatic equivalent

Simulate the Specific Segment

When you simulate the model, the following output appears in the Scope block.

Related Topics