MATLAB Answers

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

226 ビュー (過去 30 日間)
Lucas
Lucas 2012 年 8 月 1 日
コメント済み: X W 2017 年 8 月 6 日
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?

  1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 1 日
why do you want to pause it?

サインインしてコメントする。

採用された回答

Teja Muppirala
Teja Muppirala 2012 年 8 月 2 日
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');

  0 件のコメント

サインインしてコメントする。

その他の回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 8 月 1 日
編集済み: John Kelly 2015 年 3 月 2 日
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.

  2 件のコメント

Kaustubha Govind
Kaustubha Govind 2012 年 8 月 2 日
Then Teja's suggestion is the way to go!
X W
X W 2017 年 8 月 6 日
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?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by