How to connect a Subsystem's outputPorts (more than 5) to "Bus Creator" programmatically (from scripting)
2 views (last 30 days)
Show older comments
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');
0 Comments
Accepted Answer
Suman
on 26 Sep 2024
Edited: Suman
on 26 Sep 2024
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");
More Answers (0)
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!