| Contents | Index |
| On this page… |
|---|
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.
| Step | Task | Reference |
|---|---|---|
| 1 | Define the SimState for your chart. | Defining the SimState |
| 2 | Load the SimState for your chart. | Loading the SimState |
| 3 | Simulate the specific segment. | Simulating the Specific Segment |
Open the model.
Type sf_boiler at the command prompt.
Enable saving of a SimState.
Open the Configuration Parameters dialog box and go to the Data Import/Export pane.
Select the Final states check box.
Enter a name, such as sf_boiler_ctx01.
You can choose any alphanumeric string for the name.
Select the Save complete SimState in final state check box.
Click Apply.
Define the start and stop times for this simulation segment.
In the Configuration Parameters dialog box, go to the Solver pane.
For Start time, enter 0.
For Stop time, enter 400.
Click OK.
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.
Disable saving of a SimState.
This step prevents you from overwriting the SimState you saved in the previous step.
Open the Configuration Parameters dialog box and go to the Data Import/Export pane.
Clear the Save complete SimState in final state check box.
Clear the Final states check box.
Click OK.
Enable loading of a SimState.
Open the Configuration Parameters dialog box and go to the Data Import/Export pane.
Select the Initial state check box.
Enter the variable that contains the SimState of your chart: sf_boiler_ctx01.
Click Apply.
Define the new stop time for this simulation segment.
In the Configuration Parameters dialog box, go to the Solver pane.
For Stop time, enter 600.
Click OK.
You do not need to enter a new start time because the simulation continues from where it left off.
When you simulate the model, the following output appears in the Scope block.

![]() | Benefits of Using a Snapshot of the Simulation State | Testing a Unique Chart Configuration | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |