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