How to use a For iterator

39 ビュー (過去 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 Center および File ExchangeSubsystems についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by