Run a simulink model for a certain amount of time and pause
172 views (last 30 days)
Show older comments
Lucas on 1 Aug 2012
If there any way that you can run a simulink model from the command line for a certain amount of time, and then pause the model? I tried:
But it runs the model for whatever times in the model EndTime dialog box (set to 10 seconds), before it leaves that line of code. If my time step is 250 m/s, is there anyway to tell the model to run for 1 second or 4 cycles and to pause? I know about:
But I can't get 'start' to do anything other than to run the full amount of time. Thanks.
Is there anyway to load/open a simulink model in into a paused state?
Teja Muppirala on 2 Aug 2012
If you know the times that you want to stop and restart it at, could you maybe use the SimState to resume the simulation, something like this?
mdl = bdroot;
set_param(mdl, 'SaveFinalState', 'on', 'FinalStateName',...
[mdl 'SimState'],'SaveCompleteFinalSimState', 'on')
[t1, Y1] = sim(mdl, [0 15]);
set_param(mdl, 'LoadInitialState', 'on', 'InitialState',...
[t2, Y2] = sim(mdl, [15 25]);
hold on; plot(t2,Y2,'r');
set_param(mdl, 'LoadInitialState', 'off');
More Answers (2)
Kaustubha Govind on 1 Aug 2012
Edited: John Kelly on 2 Mar 2015
The easiest way to do this is to configure the Assertion block to function as a Pause block and place it in your model - the snapshot on that page shows how you can use the Clock block to pause simulation at a a certain time.
Siddharth Kamila on 13 Jun 2022
Edited: Siddharth Kamila on 13 Jun 2022
In my case in my simulink model, I need to pause and resume the simulation for every 0.05 sec time interval, while running the simulation from 0 sec to 5 sec. So how to assign the variable to the simulation time, in simulink.
Muntaha on 16 Jan 2023
Edited: Muntaha on 16 Jan 2023
My question if i keep the constant block to 0 and give the pause time to 5 second and then change the constant block to 1 .and then run the model .why does step response comes at 6th second.I want an idea to get the response at 5th second itself.
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!