Stretch an For-Iterator Subsystem over multiple timesteps

Hello,
I would like to know if there is an convinient solution to stretch an For-Iterator Subsystem over multiple timesteps. As of right now all of the 5 Iterations are calculated within one timestep. Is it possible to assign that 3 of those Iterations are done in one timestep and the other 2 in the next timestep?
I hope it is possible to understand what i am trying to achieve.
Thanks in advance.

답변 (1개)

Jonas
Jonas 2021년 5월 27일

1 개 추천

That is not possible within the functionality of a for-loop (which is what a For-Iterator is). If it would be possible, the execution of the whole for-loop would not be deterministic, and that's bad.
What you can do, is execute the For-Iterator Subsystem in a lower sample rate, for example one which is twice as slow. Then, the results will only be ready after two iterations of your main loop. Then you will need to use Rate Transition blocks to make handle reading and writing of signals in between the two sample rate tasks.

댓글 수: 2

Thank you for your answer! How exactly can i execute the Subsystem at a lower sample rate? Inside the Subsystem only const. or inherited sample rates are possible...
There are a few ways.
You can create two Function Call Subsystems, and call them with a Function Call Generator block where you set the sample time.
https://nl.mathworks.com/help/simulink/ug/using-function-call-subsystems.html
If you have Stateflow, you can trigger the Function Call Subsystems with an inherit sample time, where Stateflow triggers the one subsystem each time, but the second every other sample (using a counter for example). The Stateflow needs to output an 'event', it is a function call.

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

카테고리

도움말 센터File Exchange에서 Schedule Model Components에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 5월 26일

댓글:

2021년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by