Stretch an For-Iterator Subsystem over multiple timesteps
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Jonas
on 27 May 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 Comments
Jonas
on 28 May 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.
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!