Main Content

Simulink.Bus.addElementToPort

Add element to root input bus element port

Description

example

Simulink.Bus.addElementToPort(model,port,element) adds the specified element element to the specified root input bus element port port in the specified model model. This function does not add a block to the model.

Examples

collapse all

Suppose you want to create a model that receives a bus. The input bus contains a bus named sinusoidal, a signal named constant, and a bus named nonsinusoidal. The sinusoidal bus contains signals named sine and chirp. The nonsinusoidal bus contains signals named pulse and saw.

Open a new model named myModel.

model = new_system("myModel");
open_system(model);

Add an In Bus Element block to the model. Name the port myBusPort, and specify sine as the element selected by the block. When you specify sine, use dots to indicate the levels of bus hierarchy.

add_block("simulink/Ports & Subsystems/In Bus Element",...
    "myModel/In Bus Element",...
    PortName="myBusPort",...
    Element="sinusoidal.sine");

When you do not specify an element for the block to select, by default, the block selects an element named signal1.

Add the remaining elements to the input port that corresponds with the In Bus Element block.

Simulink.Bus.addElementToPort("myModel",...
    "myBusPort",...
    "sinusoidal.chirp");
Simulink.Bus.addElementToPort("myModel",...
    "myBusPort",...
    "constant");
Simulink.Bus.addElementToPort("myModel",...
    "myBusPort",...
    "nonsinusoidal.pulse");
Simulink.Bus.addElementToPort("myModel",...
    "myBusPort",...
    "nonsinusoidal.saw");

Input Arguments

collapse all

Model name, specified as a character vector or string scalar.

Data Types: char | string

Root input bus element port name, specified as a character vector or string scalar.

Limitations

Input bus element ports of subsystems are not supported.

Data Types: char | string

New bus element, specified as a character vector or string scalar.

For elements of nested buses, use dots to indicate each level of bus hierarchy. For example, to add a nested bus named sinusoidal with an element named sine, set element to sinusoidal.sine.

To add an element to a bus when a Simulink.Bus object specifies the bus hierarchy, edit the Bus object.

Data Types: char | string

Alternative Functionality

In the In Bus Element block dialog box, click the Add element button arrow. Then, select Add element without block.

Version History

Introduced in R2022b