How do I freeze a Simulation in Simulink, close MATLAB

S
sanjana · Oct 11, 2021 · 2.3K views
Question
I would like to run a simulation in Simulink following the below steps:   1. Run the simulation from time 0 to 10s   2. Stop the simulation at time 10s and save all the states and operating points of the simulation at that timestep   3. Close MATLAB   4. Re-open MATLAB/Simulink and then re-run that same model starting from time 10s to 20s and starting from the operating point and states I saved at time 10s. I do not want the model to restart the simulation from time 0 and lose the final simulation state of step 1.   How can the above workflow be achieved? 
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Sep 18, 2026






How to Freeze, Save, and Resume Simulink Simulations


Simulink allows you to capture the entire internal state of a simulation (integrator states, solver history, discrete delays, block execution memory) as a SimState object. You can save this state to disk and resume execution from that exact time point.

Method 1: Programmatic Workflow with MATLAB Code

Step 1: Run and Save the SimState (Phase 1: 0 to 10 Seconds)


Configure model parameters to export the complete operating state at the end of the run.

model = 'vdp'; % Replace with your model name
load_system(model);

% Configure model to save complete SimState
set_param(model, 'SaveCompleteSimState', 'on');
set_param(model, 'SaveFinalState', 'on');
set_param(model, 'FinalStateName', 'savedSimState');
set_param(model, 'StopTime', '10.0');

% Run Phase 1
out1 = sim(model);

% Extract and save the SimState to a .mat file
frozenState = out1.savedSimState;
save('checkpoint_t10.mat', 'frozenState');
fprintf('Simulation frozen and saved at t = 10s.\n');

Step 2: Load the Saved State and Resume (Phase 2: 10 to 25 Seconds)


Load the stored SimState object, set it as the initial state, and extend the stop time.

% Load the saved state from disk
load('checkpoint_t10.mat', 'frozenState');

% Configure model to start from the saved operating point
set_param(model, 'LoadInitialState', 'on');
set_param(model, 'InitialState', 'frozenState');

% Set new time boundaries
set_param(model, 'StartTime', '10.0');
set_param(model, 'StopTime', '25.0');

% Resume simulation
out2 = sim(model);
fprintf('Simulation resumed from t = 10s to t = 25s successfully.\n');

Method 2: GUI Configuration in Simulink



  1. Open your model and press Ctrl+E to open Configuration Parameters.

  2. Select Data Import/Export in the left tree.

  3. To Save State:
       

             
    • Check Final states.

    •        
    • Set variable name (e.g. xFinal).

    •        
    • Check Save complete SimState in an operating point object.

    •    


  4. To Resume State:
       

             
    • Check Initial state.

    •        
    • Enter the workspace variable name (e.g. xFinal).

    •        
    • Update Start time in the Solver pane to match the freeze time.

    •    


Method 3: Live Interactive Pause and Resume


Control live execution directly from the MATLAB command window or scripts:

% Pause a running simulation
set_param(model, 'SimulationCommand', 'pause');

% Resume a paused simulation
set_param(model, 'SimulationCommand', 'continue');

% Stop and terminate
set_param(model, 'SimulationCommand', 'stop');

SimState Rules and Limitations













ComponentSupported in SimStateNotes
Continuous IntegratorsYesPreserves derivatives and solver history.
Discrete Unit Delays / MemoryYesRetains exact buffer values.
Stateflow ChartsYesStores active state hierarchy and local variables.
MATLAB Function BlocksYesPersistent variables are stored.
Structural Model EditsNoDo not alter model topology between save and resume.


Fast Restart Tip: If you plan to run multiple sweeps starting from the same frozen baseline, enable Fast Restart (set_param(model, 'FastRestart', 'on')). This skips model recompilation on every resume.



100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!