How to connect a Subsystem's outputPorts (more than 5) to "Bus Creator" programmatically (from scripting)

3 ビュー (過去 30 日間)
Hi, Suppose I have Subsystems block which has outputs more than 5.
I have added "Bus Creator" using:
add_block("simulink/Commonly Used Blocks/Bus Creator","testing_bus/Bus Creator")
This is creating Bus in testing_bus model with only 2 input ports. Is there a way to create a "Bus Creator" with number of inputs = Size of Subsystem's Outputports?
(or)
edit the number of input port of "Bus Creator" so that later using for loop, for connections by:
add_line('testing_bus','Subsystem/1','Bus Creator/1');

採用された回答

Suman
Suman 2024 年 9 月 26 日
編集済み: Suman 2024 年 9 月 26 日
Hi Arepalli,
To add a new "Bus Creator" block with "n" number of Inputs, you can pass an additional name-value parameter in the "add_block" function as follows:
>> add_block("simulink/Commonly Used Blocks/Bus Creator","testing_bus/Bus Creator", "Inputs", "5");
This will create a Bus Creator block named "Bus Creator" with 5 input ports.
Similarly, to edit the number of ports in an existing block, you can pass this "Inputs" name-value parameter to the "set_param" function for a given block.
>> set_param("path_to_block", "Inputs", "7");

その他の回答 (0 件)

カテゴリ

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