which one do u prefer when making for loop in simulink

Now i try to make for loop system in simulink.
I know that there are two main way to make for loop. Using for iterator or making using state flow.
But i dont know which one is better way to make for loop system in model control
would you recomend me?

답변 (1개)

Mark McBroom
Mark McBroom 2022년 12월 29일

0 개 추천

The third option is MATLAB Function block. https://www.mathworks.com/help/ecoder/ug/for-loop.html
The decision on which to use is purely up to you and your desired modeling pattern. If you are using primarily Simulink then I would recommend using the Simulink For Iterator or For Each Subsystem.
Using Stateflow or ML Function block results in a slighty longer initialization time ( C code is generated and compiled for simulation ).
Thanks.
Mark.

댓글 수: 3

Thank you for your good recomendation! There is one more question. when we use Forloop subsystem, it is impossible to watch the data state in the middle of loop system. it shows olny last index of loop. So it is little bit difficult to debug. is there any effective way to debug Forloop subsystem?
Can you temporarily run the signals of interest out of the subsystem and then watch the data?
when i put a break point or make pause the run, i cant see the interner data of the for loop.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2022년 12월 28일

댓글:

2023년 1월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by