Conditionally stop simulation in simulink
조회 수: 12 (최근 30일)
이전 댓글 표시
Hi,everyone!
I want to detect a signal x in simulink and stop the simulation when it exceeds the limit a. How should I do it?
Thanks for your answer.
댓글 수: 0
채택된 답변
Harsh Sharma
2024년 10월 11일
Hi Ting,
You can connect “compare to constant” block to the signal “x” and then connect the output of that block to “stop simulation” block. In the compare to constant block, you can set the “operator” parameter to “>” and “constant value” parameter to “a”. This setup will stop the simulation when the value of signal “x” exceeds the limit “a”.
Below is an example of “ramp” signal with slope 1 which is set to stop when the signal value exceeds 3.
The output in scope is –
The simulation stops after T=3 when the signal value exceeds 3.
You can check the below documentation links to learn more about the “stop simulation” and “compare to constant” blocks –
“stop simulation” - https://www.mathworks.com/help/simulink/slref/stopsimulation.html
“compare to constant” - https://www.mathworks.com/help/simulink/slref/comparetoconstant.html
I hope this answers your question.
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!