Create a Simulink model using command Lines

Hello!
I'm trying to create a Simulink model using command Lines. So my goal is to connect a subsystem to a inductor inside a for loop or more precisely connect the right port of the subsystem to the left port of the inductor inside a for loop (files attached)
My question is: how can i connect a susbsystem to a inductor using command lines?
thanks in advance

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 4 月 12 日

1 投票

6 件のコメント

Ibrahim Ben Mrad
Ibrahim Ben Mrad 2022 年 4 月 12 日
Hello SIr,
thanks for your answer. And what arguments do i need to put in "add_line()" so line is drawn (picture attached)?
i need to use command lines so the line is drawn between the the right port of the subsystem (HF1) to the left port of the inductor
thanks in advance!
Fangjun Jiang
Fangjun Jiang 2022 年 4 月 12 日
See doc. usually add_line('connect_model','Constant/1','Gain/1'); SimScape blocks might be different. Again, see doc.
Fangjun Jiang
Fangjun Jiang 2022 年 4 月 12 日
編集済み: Fangjun Jiang 2022 年 4 月 12 日
For example, The line already existed in your picture above can be done by:
add_line(gcs,'Inductor/RConn1','Resistor/LConn1')
Ibrahim Ben Mrad
Ibrahim Ben Mrad 2022 年 4 月 12 日
編集済み: Ibrahim Ben Mrad 2022 年 4 月 12 日
Hello Sir,
thx for your answer. ive tried that one (the command "add_line(gcs,'Resistor/RConn1','Resistor1/LConn1')" but it only works if you want to connect only two Resistors. if you want to use lets say a for loop (for k=1:9) that connects two resistors to each others nine times then it would be diffucult to use that command because you have to add "num2str(k)" so therefore the error would come out that you can't use many arguments in the command "add_line". So my ideo was to use "strcat".
My question was how can i connect the subsystem to the inductor like you saw in the picture. I think it is a little bit different then the normal add_line command, is that so?
regards
Fangjun Jiang
Fangjun Jiang 2022 年 4 月 12 日
add_line(gcs,'HF1/RConn1','Inductor/LConn1')
Ibrahim Ben Mrad
Ibrahim Ben Mrad 2022 年 4 月 12 日
yes!
thx a lot it worked for me
again with strcat because of the for-Loop
regards

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

カテゴリ

ヘルプ センター および File ExchangeProgrammatic Model Editing についてさらに検索

質問済み:

2022 年 4 月 12 日

コメント済み:

2022 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by