Filter löschen
Filter löschen

How to use a For iterator

12 Ansichten (letzte 30 Tage)
Zhenteng Shen
Zhenteng Shen am 31 Jul. 2017
Beantwortet: Swarooph am 1 Aug. 2017
Hi everyone, I'm new this Simulink, my situation is basically: I have a control map (function of 3 variables), 2 of the inputs stay constant and one input can take 5 different values, instead of having 5 different map reading blocks I've been told I can just make one for iteration block which I sort of attempted to do.
I proceeded to add my inputs in the For iterator subsystem but wan't sure what to do with the actual 'For iterator' inside the subsystem, where do I hook up the output to? internal or external limit source? and if I have 5 values do I want to iterate it 5 times? I want the map to be read indefinitely and in real time though.
THANK YOU!!!
  2 Kommentare
Swarooph
Swarooph am 31 Jul. 2017
Bearbeitet: Swarooph am 31 Jul. 2017
Note that there are TWO types of FOR subsystems. According to the documentation:
For Iterator Subsystem: Represent subsystem that executes repeatedly during simulation time step. Doc here.
For Each Subsystem: Repeatedly perform algorithm on each element or subarray of input signal and concatenate results. Doc here .
What you choose here depends on the kind of output you are looking for. This is a little vague from your explanation.
To me it looks like you want the second. That is, take in the 2 constant inputs and FOR EACH element in the 3rd input, read maps accordingly. The output will be a concatenated 5xn value for all the 3rd inputs together.
If this is not what you are looking for, let us know specifically with examples what output you desire. If you can include the sizes of the inputs and the expected outputs, it will be better to help as well.
Zhenteng Shen
Zhenteng Shen am 1 Aug. 2017
Thank you so much, that really helped! I have now managed to do it.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Swarooph
Swarooph am 1 Aug. 2017
Copy/pasting helpful comment as an answer:
Note that there are TWO types of FOR subsystems. According to the documentation:
For Iterator Subsystem: Represent subsystem that executes repeatedly during simulation time step. Doc here.
For Each Subsystem: Repeatedly perform algorithm on each element or subarray of input signal and concatenate results. Doc here .
What you choose here depends on the kind of output you are looking for. This is a little vague from your explanation.
To me it looks like you want the second. That is, take in the 2 constant inputs and FOR EACH element in the 3rd input, read maps accordingly. The output will be a concatenated 5xn value for all the 3rd inputs together.
If this is not what you are looking for, let us know specifically with examples what output you desire. If you can include the sizes of the inputs and the expected outputs, it will be better to help as well.

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by