MATLAB Answers

Stretch an For-Iterator Subsystem over multiple timesteps

조회 수: 1(최근 30일)
julius
julius 2021년 5월 26일
댓글: Jonas 2021년 5월 28일
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일
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
Jonas
Jonas 2021년 5월 28일
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.

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by