MATLAB: Reset Simulink model from m file

mfilesimulink

I need to reset a model within an m-file. I know using : set_param(model, 'SimulationCommand', 'start') set_param(model, 'SimulationCommand', 'stop')
can start ans stop a model within a m-file. But how about reseting – i.e. stopping the model and then re-starting from initial condition, time = 0 ? Thanks!

Best Answer

Using set_param(model, 'SimulationCommand', 'stop') followed by set_param(model, 'SimulationCommand', 'start') does restart the model from t=0. You need to use set_param(model, 'SimulationCommand', 'pause') followed by set_param(model, 'SimulationCommand', 'start') to continue where the model was paused.