Simulink.Bus.addElementToPort
Description
Examples
Add Elements to Bus Element Port
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
component
— Model name or subsystem block path
character vector | string scalar
Model name or subsystem block path, specified as a character vector or string scalar.
Data Types: char
| string
port
— Input bus element port name
character vector | string scalar
Input bus element port name, specified as a character vector or string scalar.
Data Types: char
| string
element
— New bus element
character vector | string scalar
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
.
Tips
To add an element to a bus when a Simulink.Bus
object specifies
the bus hierarchy, edit the Simulink.Bus
object.
Data Types: char
| string
Alternative Functionality
In the In Bus Element block dialog box, click the button arrow. Then, select Add element without
block.
Version History
Introduced in R2022bR2023b: Add elements to input bus element ports of subsystems
Starting in R2023b, you can add elements to an input bus at a subsystem interface and
specify the properties of those elements when you have at least one In Bus
Element block that represents the port. You no longer need a
Simulink.Bus
object to define the bus hierarchy or an In Bus
Element block to represent each element with nondefault properties. Previously,
only In Bus Element blocks at model interfaces supported this
functionality.
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)