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

8 Ansichten (letzte 30 Tage)
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');

Akzeptierte Antwort

Suman
Suman am 26 Sep. 2024
Bearbeitet: Suman am 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");

Weitere Antworten (0)

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by