Run a simulink model for a certain amount of time and pause

113 visualizzazioni (ultimi 30 giorni)
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:
set_param(modelName,'SimulationCommand','Start');
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:
set_param(modelName,'SimulationCommand','pause');
set_param(modelName,'SimulationCommand','continue');
But I can't get 'start' to do anything other than to run the full amount of time. Thanks.
EDIT -
Is there anyway to load/open a simulink model in into a paused state?

Risposta accettata

Teja Muppirala
Teja Muppirala il 2 Ago 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?
open('sldemo_bounce');
mdl = bdroot;
set_param(mdl, 'SaveFinalState', 'on', 'FinalStateName',...
[mdl 'SimState'],'SaveCompleteFinalSimState', 'on')
[t1, Y1] = sim(mdl, [0 15]);
plot(t1,Y1,'b');
set_param(mdl, 'LoadInitialState', 'on', 'InitialState',...
[mdl 'SimState']);
[t2, Y2] = sim(mdl, [15 25]);
hold on; plot(t2,Y2,'r');
set_param(mdl, 'LoadInitialState', 'off');

Più risposte (3)

Kaustubha Govind
Kaustubha Govind il 1 Ago 2012
Modificato: John Kelly il 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.
  3 Commenti
X W
X W il 6 Ago 2017
Where is the "Continue" block? "You can resume the simulation using Continue as you can for any paused simulation." - I don't want to type in or manually clock "Continue", I want the simulation to pause for x amount of time and then continue on with the signal flow out of the block automatically. I want to do this because I want to wait for a heater to cool in real life. No, I can not use Simulink dekstop real time. Is there an update to this as of 2017?
Siddharth Kamila
Siddharth Kamila il 13 Giu 2022
Modificato: Siddharth Kamila il 13 Giu 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.

Accedi per commentare.


Muntaha
Muntaha il 16 Gen 2023
Modificato: Muntaha il 16 Gen 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.

Mohammad Ali Sharifian
Mohammad Ali Sharifian il 12 Feb 2024
You can do complex operations in a m-file MATLAB code. Then run your simulink by this command: sim("simulink_file.slx").
Put these parameters in simulink start & stop and sample time as shown in picture below:
T0: Start Time
Tf: Final Time
Ts: Sampling Time
Then in your m-file code assign values to these parameters and you are done. for example you can use a for loop or if,elseif commands to further develop your code. If you want to run simulink for just a sample, simply use T0=0 & Tf=Ts.

Categorie

Scopri di più su Interactive Model Editing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by