How to use the simulation time in MATLAB
조회 수: 1 (최근 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에서 Event Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!