In Simulink, how to call the same subsystem several times to do a calculation?

2 ビュー (過去 30 日間)
I want to do a calculation for each if elseif output values(data) using a same subsystem(functionA)
if(u==1){
     data1 = 10;
     data_out1 = functionA(data1);
}
elseif(u==2){      
data2 = 20;
    data_out2 = functionA(data2);
}
elseif(u==2){
     data3 = 40;
     data_out3 = functionA(data3);
}
.
          .
else{ }
For better understanding of my question I attached the simulink model which I want to modify.
Each outputs from 'if' block should go through the ADC_To_Temp1 subsystem for additional calculation.
This is the "ADC_To_Temp1" subsystem which I want to use for the additional calculation.
Please let me know how to do this.
Thank you

採用された回答

Salman Ahmed
Salman Ahmed 2021 年 11 月 16 日
Hi Udara,
I am assuming you wish to modify your Simulink model to pass the outputs of it (HAL_HV_MON, HAL_HV_MON1, ...) to a single subsystem (ADC_To_Temp1). This can be done using a for each iterator subsystem. The set of blocks within the subsystem represents the algorithm applied to a single element of the original signal array.
The output signals can be clubbed together into a bus using a bus creator block. This bus can be converted to a vector using a bus to vector block. The vector obtained so is then applied to a for each subsystem. The for each subsystem houses the ADC_To_Temp1 logic. Have a look at sample design where I have used your subsystem and passed three values through the same instance of the subsystem. Hope it helps.
  1 件のコメント
Udara Darshana Panamulle Arachchige
Udara Darshana Panamulle Arachchige 2021 年 11 月 17 日
Hi Salman,
Thank you Salman. This was very helpful.
To seperate output data, I used Selector block after the For Each Subsystem and now I can read seperate outputs for the each input data.
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Simulink in Help Center and File Exchange

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by