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

조회 수: 2 (최근 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 CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by