Stretch an For-Iterator Subsystem over multiple timesteps

1 Ansicht (letzte 30 Tage)
julius
julius am 26 Mai 2021
Kommentiert: Jonas am 28 Mai 2021
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.

Antworten (1)

Jonas
Jonas am 27 Mai 2021
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 Kommentare
julius
julius am 27 Mai 2021
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...
Jonas
Jonas am 28 Mai 2021
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by