How can I break a WHILE or a FOR loop in Simulink?

조회 수: 22 (최근 30일)
Snehal Chauhan
Snehal Chauhan 2021년 12월 21일
답변: Abhiram 2025년 1월 29일
I want to break a for loop or a while loop in Simulink. For instance, we have break statement in C. How do I do the same in Simulink?

답변 (1개)

Abhiram
Abhiram 2025년 1월 29일
Hi Snehal,
To achieve break functionality within 'while' loops in Simulink, the 'While Iterator' block can be utilized in conjunction with other blocks to replicate the effect of a 'break' statement. Refer to the following thread for an implementation example:
Regarding 'for' loops, Simulink does not inherently support breaking out of a ‘for’ loop using the 'For Iterator' block. However, a workaround can be implemented as detailed in the provided thread:
Refer to Simulink Documentation for more information about ‘While Iterator’ and ‘For Iterator’ blocks.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by