How to use a For iterator

27 次查看(过去 30 天)
Zhenteng Shen
Zhenteng Shen 2017-7-31
回答: Swarooph 2017-8-1
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 个评论
Swarooph
Swarooph 2017-7-31
编辑:Swarooph 2017-7-31
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 2017-8-1
Thank you so much, that really helped! I have now managed to do it.

请先登录,再进行评论。

回答(1 个)

Swarooph
Swarooph 2017-8-1
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.

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by