How to use the simulation time in MATLAB
2 ビュー (過去 30 日間)
表示 古いコメント
Hello,
The way I am trying to simulate is like : Run a simulink model for 1 sec. pause the simulation, update the parameters and resume the simulation. I want to continue this cycle for 100 sec. I have used the following MATLAB commands
set_param('Model_Name','SimulationCommand','start') To start the simulation
set_param('Model_Name','SimulationCommand','pause') to pause the suimulation
set_param('Model_Name','SimulationCommand','update') to update the suimulation
set_param('Model_Name','SimulationCommand','continue') to resume the suimulation
Only problem I am facing is to pause the simulation after 1 sec. I try to use the clock in simulink and feed the output of the clock to the MATLAB using "To WorkSpace". it creates a vector. As a result, I could not use this time for my purpose.
In case, someone has solved this problem, I would greatly appreciate if you could kindly share your solution.
Thanks in advance
0 件のコメント
回答 (1 件)
Fangjun Jiang
2019 年 8 月 8 日
Create a 1Hz trigger (e.g. Pulse Generator with amplitude of 1 and period of 1), feed it to a "Not" block and then an "Assertion" block. The simulation will pause automatically every 1 second.
Uncheck "Stop simulation when assertion fails". add the below lines as the simulation callback
set_param(...);
set_param('ModelName','SimulationCommand','update');
set_param('ModelName','SimulationCommand','continue');
Note that the Pulse Generator may trigger more pauses if the step size is less than 0.05. The point is to make a 1Hz trigger based on your simulation settings.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Sources についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!