How to use a For iterator

조회 수: 29 (최근 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