Main Content


Restore simulation scenario and model to their previous state

Since R2024a



    simulator_out = restore(simulator) restores the configuration set, signal logging, fast-restart state, dirty state, and any other simulation arguments changed by the setup function.


    collapse all

    Open the model.

    model = "sdoHydraulicCylinder";

    Create a simulation scenario for the model.

    simulator = sdo.SimulationTest(model);

    Configure the model and simulator for optimization and simulation, enabling fast restart.

    simulator = setup(simulator,FastRestart="on");

    Simulate the model.

    simulator = sim(simulator);

    The first simulation in fast restart mode requires the model to compile. Subsequent simulations execute in fast restart mode and reuse the compiled data.

    Adjust tunable model parameters.

    Ac = sdo.getParameterFromModel(model,"Ac");
    Ac.Value = 0.5;
    simulator.Parameters = Ac;

    Simulate the model again.

    simulator = sim(simulator);

    The model simulates in fast restart mode.

    Restore the simulator to its initial configuration, which disables fast restart.

    simulator = restore(simulator);

    Input Arguments

    collapse all

    Simulation scenario for Simulink® model, specified as an sdo.SimulationTest object. A simulation scenario specifies input signals, model parameter and initial state values, and signals to log for a model.

    Output Arguments

    collapse all

    Restored simulation scenario, returned as an sdo.SimulationTest object.


    • You can add a cleanup function to ensure that the restore function always runs, even when the optimization generates an error.

      simulator = sdo.SimulationTest('mymodel');
      simulator = setup(simulator);
      scenario_cleanup = onCleanup(restore(scenario));

    Version History

    Introduced in R2024a