Skip to Main Content Skip to Search
Product Documentation

Dividing a Long Simulation into Segments

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 SimState at time t = 400, and then load that SimState for simulation between t = 400 and 600.

StepTaskReference
1Define the SimState for your chart.Defining the SimState
2Load the SimState for your chart.Loading the SimState
3Simulate the specific segment.Simulating the Specific Segment

Defining the SimState

  1. Open the model.

    Type sf_boiler at the command prompt.

  2. Enable saving of a SimState.

    1. Open the 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.

      You can choose any alphanumeric string for the name.

    4. Select the Save complete SimState in final state check box.

    5. Click Apply.

     Programmatic equivalent

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

    1. In the 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 simulation state at t = 400 in the variable sf_boiler_ctx01 in the MATLAB base workspace.

  5. Disable saving of a SimState.

    This step prevents you from overwriting the SimState you saved in the previous step.

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

    2. Clear the Save complete SimState in final state check box.

    3. Clear the Final states check box.

    4. Click OK.

     Programmatic equivalent

Loading the SimState

  1. Enable loading of a SimState.

    1. Open the 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 SimState of your chart: sf_boiler_ctx01.

    4. Click Apply.

     Programmatic equivalent

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

    1. In the 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

Simulating the Specific Segment

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

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS