In Bus Element
Select input from external port
Libraries:
Simulink /
Ports & Subsystems
Simulink /
Sources
HDL Coder /
Ports & Subsystems
HDL Coder /
Sources
Alternative Configurations of In Bus Element Block:
Bus Element In
Description
The In Bus Element block selects input from an external port that receives a bus, signal, or message.
When the port receives a bus, the In Bus Element block combines the functionality of an Inport block and a Bus Selector block. To select multiple elements from the bus, use multiple In Bus Element blocks. All In Bus Element blocks that correspond with the same port share a dialog box.
For interfaces that include buses composed of many bus elements, In Bus Element blocks:
Reduce signal line complexity and clutter in a block diagram.
Allow you to more easily make incremental changes to the interface.
Allow access to a bus element closer to the point of usage, avoiding the use of a Bus Selector and Goto block configuration.
To convert an interface to use In Bus Element blocks, see Simplify Subsystem and Model Interfaces with Bus Element Ports.
The In Bus Element block does not support mixing message and signal elements as outputs.
Examples
In a model component, each input bus element port is represented by one or more In Bus Element blocks.
Open the model named CreateInputBusElementPort
.
How you add a bus element port depends on whether you are in the model component or its parent.
To add an input bus element port to the currently open subsystem or model, add an In Bus Element block. For example, double-click the canvas and start typing the block name. Then, select the In Bus Element block.
To add an input bus element port to a Subsystem or Model block in the current component, click the edge of the block and select Create in bus port. For example, add an input bus element port to the Subsystem block.
To open the subsystem, double-click the Subsystem block.
The subsystem contains a default In Bus Element block that corresponds to the input port you created on the Subsystem block. The block label uses default values for its two interactive text fields: the port name (InBus
) and the bus element (signal1
).
To create another input bus element port from inside a model component, hold Ctrl while you drag an existing In Bus Element block to a new location. Upon releasing the pointer, click New Port.
An In Bus Element block with a unique port name appears.
In this example, the new port is named InBus1
.
To edit the port name, click the port name in the block label. Then, enter a new name.
Alternatively, set the Port name block parameter.
When multiple blocks are associated with the same port and you change the name of the port, all blocks that share the port update to reflect the new port name.
The input to a bus element port can be a bus, signal, or message. To pass the entire input through an In Bus Element block instead of selecting an element of an input bus, remove the part of the block label that represents an element.
Open and compile the model named SelectTopLevelInput
. To compile the model, on the Modeling tab of the Simulink® Toolstrip, click Update Model or Run. Compiling the model updates the line styles, which you can use to visually identify buses.
The Subsystem block has ports named InBus
and Constant
. One of the ports connects to a bus. The other port connects to a signal.
Open the subsystem, which contains one In Bus Element block per port.
The top In Bus Element block selects the element named chirp
from the port named InBus
.
The bottom In Bus Element block selects the entire input from the port named Constant
. The entire input is a constant signal.
To select the entire input from the port named InBus
, delete the second text field from the block label. For example, click chirp
to edit the text field.
Then, delete chirp
. To commit the change, click elsewhere on the canvas.
Update the line styles by compiling the model.
The In Bus Element block passes the entire input into the subsystem. In this case, the entire input is the top-level bus for the port.
To propagate the signal labels, in the Simulink Toolstrip, on the Debug tab, click Information Overlays. Then, select Propagated Signal Labels.
The propagated names indicate that the In Bus Element blocks pass the bus named nonconstant
and the signal named constant
into the subsystem.
To pass a top-level bus into a referenced model using an In Bus Element block, you must perform one of these actions using the In Bus Element block:
Define the bus with a
Simulink.Bus
object.Specify at least one leaf element of the bus with or without another In Bus Element block.
To select elements from an input bus element port, use an In Bus Element block for each element that you want to select.
Open and compile the example model named SelectInputBusElements
. To compile the model, on the Modeling tab of the Simulink Toolstrip, click Update Model or Run. Compiling the model updates the line styles, which you can use to visually identify buses.
A Bus Creator block creates a virtual bus that contains two elements: a nested bus named nonconstant
and a signal named constant
. The nonconstant
bus contains two signals named sine
and chirp
. The top-level bus connects to the input port of the Subsystem block.
To open the subsystem, double-click the Subsystem block. The subsystem contains an In Bus Element block that corresponds to the input port.
The block label indicates that the block selects the signal named constant
from the input port.
To change the element that the block selects, edit the second text field in the block label. When the block represents a subsystem input port and the second text field is empty, a menu provides the elements of the port along with the previously selected element.
When the list of input elements is long, filter the list of elements by starting to type the name of the element you want to select.
For this example, type chirp
.
The list provides the text you type as an option. However, the top-level input bus does not contain a signal named chirp
. The nested bus named nonconstant
contains the signal named chirp
. Therefore, select the option named nonconstant.chirp
. A dot separates each level in the bus hierarchy.
Open the Property Inspector. Then, select the In Bus Element block. Alternatively, double-click the block to open a dialog box.
The element that the block selects is highlighted. The elements that an In Bus Element block does not select are gray and italicized.
To add blocks for additional input elements, click an element name or hold Ctrl as you click multiple element names. Then, click .
Corresponding In Bus Element blocks appear in the block diagram.
Multiple In Bus Element blocks can select the same element. For example, add another block that selects the element named constant
.
The duplicate block is highlighted.
Connect the In Bus Element blocks to other blocks. To propagate signal labels, in the Simulink Toolstrip, on the Debug tab, click Information Overlays. Then, select Propagated Signal Labels.
The In Bus Element blocks propagate the names of the selected elements. For example, the In Bus Element block labeled InBus.nonconstant.chirp
propagates the name <chirp>
to the output signal.
To specify the elements of a bus at a bus element port, you can:
Add elements to the interface with or without adding blocks to the block diagram.
Define the bus hierarchy with a
Simulink.Bus
object.
This example shows how to define a bus at an input bus element port without a
Simulink.Bus
object.
In a blank model or subsystem, add an In Bus Element block.
Open the Property Inspector. Then, select the In Bus Element block. Alternatively, double-click the block to open a dialog box.
To add an element to the port without a block, select the element that you
want to contain the new element. For example, select
InBus
. Then, click the button arrow, and select Add
element without block.
The new element is nested under the previously selected element. The block diagram is unchanged.
The element name is gray and italicized to indicate that an In Bus Element block does not represent the element directly.
By adding elements without adding blocks, you can define the entire bus
hierarchy with only one In Bus Element block and without a
Simulink.Bus
object.
Optionally:
Add more elements with or without blocks.
Rename elements by double-clicking their names and entering new names.
Reorder elements by dragging them to new locations.
Specify element properties.
Defining the properties of elements at an interface is useful when you create a file for reuse. The interface definition determines the input that a referenced subsystem or model supports. The hierarchy and properties of the input bus must match the definition at the corresponding port.
Suppose you add elements without blocks then decide that you want
In Bus Element blocks that select the elements. To add
blocks for input elements, click an element name or hold
Ctrl as you click multiple element names. Then, click . For example, add blocks for
Chirp
and Sine
.
Corresponding In Bus Element blocks appear in the block diagram.
You can add multiple In Bus Element blocks that represent the same element.
An In Bus Element block can expect elements that are not available at the corresponding input port.
To remove the invalid elements and all In Bus Element blocks that select them, in the Property Inspector or dialog box:
Select the invalid elements to remove.
For a subsystem interface, when an element is not available in the input bus, the element name is red. When you pause on the element name, a tooltip indicates that the element is not in the input bus.
Click
.
For example, suppose you have a subsystem interface that receives a bus named
InBus
. An element named pulse
has been removed
from the input bus. However, at least one In Bus Element block selects
the element.
To remove the blocks that select the invalid element, click the element name. Then,
click .
The operation removes the invalid element and corresponding block.
When you select an element that is available at the input port of a subsystem, and
then click , you remove all In Bus Element blocks that select
the element. The element remains in the list because it is part of the input bus.
When multiple In Bus Element blocks select the same element, selecting one of the blocks highlights the other blocks that select the same element.
Open the model named ModelingControllerStandalone
.
Select one of the In Bus Element blocks labeled sensor.x1
.
The block diagram highlights the other In Bus Element block labeled sensor.x1
, indicating that the block is a duplicate of the selected In Bus Element block.
Suppose you have a more complicated controller model that uses more than two In Bus Element blocks that select sensor.x1
from the input port.
To find duplicate blocks when the block diagram is complicated, select the block, pause on the ellipsis, and in the action bar, click Related Blocks.
When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. Clicking a related block in the list selects the block in the block diagram.
Use compact labels and block colors to customize the appearance of In Bus Element and Out Bus Element blocks.
Open the model named BusElementPortBlocks
.
The model contains:
In Bus Element blocks that represent two unique bus element ports named
InBus
andpulse
Out Bus Element blocks that represent a bus element port named
OutBus
To reduce the size of the block labels, display only the leaf element names. Select an In Bus Element or Out Bus Element block, pause on the ellipsis, and in the action bar, click Compact Notation.
All In Bus Element and Out Bus Element blocks in the block diagram display shortened block labels that use only the leaf element name.
To show the full block label, in the action bar, you can click Expanded Notation. For this example, keep the compact block labels.
Block colors can help differentiate unique ports when the block labels are compact.
Open the Property Inspector. Then, select an In Bus Element block that corresponds with the port named InBus
. For example, select the block labeled constant
. Alternatively, double-click the block to open a dialog box.
In the Property Inspector or dialog box, select InBus
. Then, click and select a standard color or specify a custom color. For this example, select cyan.
The blocks related to the port use the chosen color.
To identify the blocks that select the nested bus named nonconstant
or its elements, select nonconstant
. Then, click and select a standard color or specify a custom color. For this example, select magenta.
The blocks related to the nested bus use the chosen color.
Extended Examples
Simulink Bus Capabilities
Work with buses in components, simplify component interfaces, and streamline common bus workflows.
Programmatically Create Bus Element Ports
Add blocks for bus element ports and specify element attributes using MATLAB® functions.
Load Input Data for Bus Using In Bus Element Blocks
Load input data for a bus using In Bus Element blocks.
Use Model-Based Design to Build a Battery Management System
Build a battery management system using a workflow that highlights the best practices and tools for collaborative design.
Ports
Output
Select a bus, signal, or message from the corresponding external input port of the parent subsystem or model.
While you can select bus elements, you cannot select elements of arrays of buses.
Data Types: single
| double
| half
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| string
| Boolean
| fixed point
| enumerated
| bus
Complex Number Support: Yes
Parameters
To edit the element associated with an In Bus Element block, in the Simulink® Editor, edit the block label.
To edit port, signal, execution, and message attributes, use the Property Inspector. From the Simulink Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Block Label
Specify a port name that is not already in use by another block or port within the system. The name appears on the parent Subsystem or Model block.
To change the port name from the Simulink Editor, edit the first text field of the block label.
Multiple blocks can access the same port.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | PortName |
Values: | "InBus" (default) | port name in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/PortBlock",PortName="myBus")
When the port receives a bus from the parent system, optionally specify an element to select from the bus.
To specify the element that the block selects, in the Simulink Editor, edit the second text field of the block label.
How you specify the element depends on where the element is in the bus hierarchy.
For an element at the top level of the input bus, specify the element name, for example,
constant
.For an element in a nested bus, specify the name of the nested bus, intermediary nested buses, and the leaf signal separated by dots, for example,
sinusoidal.sine
. This element path does not include the top-level bus.
Multiple blocks can access the same element.
To select the top-level signal, message, or bus, delete the text from the second text field of the block label.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | Element |
Values: | "signal1" (default) | element path in quotes |
Example: set_param("mymodel/Subsystem1/PortBlock",Element="constant")
Example: set_param("mymodel/Subsystem1/PortBlock",Element="sinusoidal.sine")
Port Tab
To toggle whether the tabs are visible, click .
For information about the port name, see Port name.
Specify the order in which the port that corresponds to the block appears on the parent Subsystem or Model block.
If you add a block that creates another port, the port number is the next available number.
Deleting all blocks associated with a port deletes the port. Other ports are renumbered so that they are sequential and do not skip any numbers.
Specifying a port number that exceeds the number of ports creates a port for that number and for any skipped sequential numbers.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | Port |
Values: | "1" (default) | real integer in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/PortBlock",Port="5")
Signal Tab
To toggle whether the tabs are visible, click .
When you specify attributes, a parenthetical appears next to the name of the corresponding bus, signal, or message. To display the specified attributes in full, click the attribute summary.
Before R2025a: To specify attributes, such as data type, pause on the
name of a bus, signal, or message. Then, click . Alternatively, when available, click an attribute
summary.
The data type of a bus, signal, or message can be inherited, specified directly, or
expressed as a data type object such as a Simulink.NumericType
object.
You can specify any of these options:
Inherited data type
Built-in Simulink data type — For example, specify
single
oruint8
. See Data Types Supported by Simulink.Fixed-point data type — Use the
fixdt
function. For example, specifyfixdt(1,16,0)
.Enumerated data type — Use the name of the type preceded by
Enum:
. For example, specifyEnum: myEnumType
.Bus data type — Use the name of the
Simulink.Bus
object preceded byBus:
. For example, specifyBus: myBusObject
.Value type — Use the name of the
Simulink.ValueType
object preceded byValueType:
. For example, specifyValueType: windVelocity
.Custom data type — Use a MATLAB expression that specifies the type. For example, you can specify a
Simulink.NumericType
object whoseDataTypeMode
property is set to a value other than"Fixed-point: unspecified scaling"
.
When you specify a Simulink.ValueType
object as the data type, some parameters of the element are ignored. For example, the
Min, Max, and Unit parameters
are ignored. The software uses the corresponding properties of the
Simulink.ValueType
object. For example, suppose you set
Unit to ft/s
for an element. When the Data
type of the element specifies a ValueType
object that has
m/s
as its unit, the element uses m/s
instead of
ft/s
.
When you specify a Simulink.Bus
object
as the data type, some parameters of the element are reset to their default values. For
example, the Min, Max, and Unit
parameters are reset. The software uses the corresponding properties of the
Simulink.BusElement
objects in the Simulink.Bus
object
instead.
Tips
When you specify a bus using a
Simulink.Bus
object or aSimulink.ValueType
object with aSimulink.Bus
object data type, the Property Inspector and block dialog box display the elements defined by the correspondingSimulink.BusElement
objects.To create a
Simulink.Bus
object using the Type Editor, click.
Dependencies
To specify a Simulink.Bus
object as the data type of a bus at a bus
element port, an
In Bus Element
block must represent the bus or an element of the bus.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | OutDataTypeStr |
Values: | "Inherit: auto" (default) | "double" | "single" | "half" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64" | "boolean" | "fixdt(1,16)" | "fixdt(1,16,0)" | "fixdt(1,16,2^0,0)" | "string" | "Enum: <class name>" | "Bus: <object name>" | "ValueType: <object name>" | data type expression in quotes |
Example: set_param("mymodel/myBus.signal1",OutDataTypeStr="int32")
Specify whether to inherit the bus virtuality or define the bus as virtual or nonvirtual. For more information, see Composite Interface Guidelines.
This parameter determines whether the blocks inherit or define the bus virtuality. If the blocks define the bus virtuality and the virtuality of the input bus does not match, compiling the model produces an error.
Dependencies
To enable this parameter, Data type must resolve to a
Simulink.Bus
object. For example, set Data type to
a Simulink.Bus
object or a Simulink.ValueType
object that
specifies a Simulink.Bus
object as its data type.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | BusVirtuality |
Values: | "inherit" (default) | "virtual" | "nonvirtual" |
Example: set_param("mymodel/myBus.nestedBus",BusVirtuality="nonvirtual")
Specify the data mode of the input element.
inherit
— Input element inherits its data mode.signal
— Input element must be a signal or a bus that contains signals.message
— Input element must be a message or a bus that contains messages.
When you choose message
as the data mode of a message
or bus, an envelope button appears next to the message or bus. Use the envelope button
to specify custom queue properties.
Tips
To specify different custom queue properties for each message in a bus, set the Data mode parameter for each message instead of the bus.
Dependencies
To enable this parameter, the block must be at the top level of a model.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | DataMode |
Values: | "inherit" (default) | "signal" | "message" |
Example: set_param("mymodel/InBus",DataMode="signal")
Specify the dimensions of a signal.
-1
— The signal can have any dimensions.N
— The signal must be a vector of sizeN
.[R C]
— The signal must be a matrix havingR
rows andC
columns.
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter to1
. The software uses the dimensions specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the dimensions specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | PortDimensions |
Values: | "-1" (default) | integer in quotes | 1 -by-2 vector of integers in
quotes |
Data Types: | char | string |
Example: set_param("mymodel/myBus.signal1",PortDimensions="[1
3]")
Specify the type of signals allowed.
Inherit
— Allow variable-size and fixed-size signals.Variable
— Allow only variable-size signals.Fixed
— Allow only fixed-size signals. Do not allow variable-size signals.
When the signal is variable-sized, the Dimensions parameter specifies the maximum dimensions of the signal.
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter toInherit
. The software uses the dimensions modes specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the dimensions mode specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | VarSizeSig |
Values: | "Inherit" (default) | "No" | "Yes" |
Example: set_param("mymodel/Subsystem1/myBus.signal1",VarSizeSig="No")
Specify the physical unit of the signal. For a list of supported units, in the MATLAB Command Window, enter showunitslist
.
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter toinherit
. The software uses the units specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the unit specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | Unit |
Values: | "inherit" (default) | unit supported by Simulink software in quotes |
Data Types: | char | string |
Example: set_param("mymodel/myBus.signal1",Unit="m/s")
Specify the numeric type of the signal. To choose the numeric type of the signal, select
auto
. Otherwise, choose a real or complex signal type.
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter toauto
. The software uses the complexity specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the complexity specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | SignalType |
Values: | "auto" (default) | "real" | "complex" |
Example: set_param("mymodel/myBus.signal1",SignalType="real")
Lower value of the range that the software checks.
This number must be a finite real double scalar value.
The software uses this value to perform:
Simulation range checking. For more information, see Specify Signal Ranges.
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter to[]
. The software uses the minimum values specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the minimum value specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | OutMin |
Values: | "[]" (default) | scalar in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/myBus.signal1",OutMin="0")
Upper value of the range that the software checks.
This number must be a finite real double scalar value.
The software uses this value to perform:
Simulation range checking. For more information, see Specify Signal Ranges.
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter to[]
. The software uses the maximum values specified by theSimulink.BusElement
objects in theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the maximum value specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | OutMax |
Values: | "[]" (default) | scalar in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/myBus.signal1",OutMax="2")
Use the description to document information about the bus, signal, or message, such as where it is used. This information does not affect processing.
Dependencies
When Data type specifies a
Simulink.Bus
object, the software sets this parameter to""
(empty). The software uses the description specified by theSimulink.Bus
object.When Data type specifies a
Simulink.ValueType
object, the software ignores the value of this parameter. The software uses the description specified by theSimulink.ValueType
object instead.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | Description |
Values: | "" (default) | description in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/myBus.signal1",Description="This signal is
used by...")
Execution Tab
To toggle whether the tabs are visible, click .
When you specify attributes, a parenthetical appears next to the name of the corresponding
bus, signal, or message. To display the specified attributes, click
.
Before R2025a: To specify execution attributes, pause on the name
of a bus, signal, or message. Then, click .
Specify the discrete interval between sample time hits or specify another type of
sample time, such as continuous (0
) or inherited
(-1
). For more options, see Types of Sample Time.
By default, the signal inherits its sample time.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | SampleTime |
Values: | "-1" (default) | scalar in quotes |
Data Types: | char | string |
Example: set_param("mymodel/Subsystem1/myBus.signal1",SampleTime="0.01")
Since R2022b
The Events parameter stores the event triggers associated with the port. Event triggers create schedule events based on the runtime activity at a particular location in the model. The schedule for the model specifies the partitions that execute in response to the schedule event, as well as the priority of execution. To configure the schedule for your model, use the Schedule Editor.
The table summarizes the event triggers you can configure on root-level input ports. Each event trigger maps an input event related to the flow of data into the port to the name of the schedule event to trigger. You can configure an input port with one event trigger for each input event.
Input Event | Input Event Description | Event Trigger Object |
---|---|---|
Input write | An input write event occurs each time the input port value updates. | simulink.event.InputWrite |
Input write timeout | An input write timeout event occurs each time the input port value does not update within a specified amount of time. | simulink.event.InputWriteTimeout |
Input write lost | An input write lost event occurs each time a new input port value overwrites unprocessed data. | simulink.event.InputWriteLost |
Event Triggers on Bus Ports
When you configure event triggers on a bus port, determine where to specify the event triggers based on the virtuality of the bus.
Virtual bus — Specify event triggers on leaf elements of the bus. Event triggers are not supported on the virtual bus itself.
Nonvirtual bus — Specify event triggers on the bus. Event triggers are not supported on elements of nonvirtual buses.
In Bus Element blocks must select each element that has one or more event triggers.
Dependencies
To enable this parameter:
The port must be a root-level input port in a rate-based model.
If the port loads a nonvirtual bus, in the hierarchical tree, select the bus. Event triggers are not supported on elements of a nonvirtual bus.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model
name,
a forward slash, and the port name or bus element path. For a bus
element port, the bus element path provides the hierarchy from the
top-level bus to the target element, separating each name in the
hierarchy with a dot.
Parameter: | EventTriggers |
Values: | [] (default) | 1 -by-1 cell
array | 2 -by-1 cell
array | 3 -by-1 cell
array |
Example: set_param("mymodel/InBusNonvirtual",EventTriggers={inputWrite,writeTimeout,writeLost})
specifies event triggers for the nonvirtual bus named
InBusNonvirtual
.
Example: set_param("mymodel/InBus.signal1",EventTriggers={inputWrite,writeTimeout,writeLost})
specifies event triggers for a leaf element named
signal1
of the virtual bus named
InBus
.
Queue Attributes
Queue attributes are visible only when the block is at the top level of a model and you
set the Data
mode parameter to message
.
To specify queue attributes, next to the name of a bus or message, click .
Use this parameter to select between default or custom queue specifications.
To use the default queue properties, leave the parameter selected. In this case, for each message bus element, a LIFO overwriting queue of capacity 1 is automatically inserted.
To use custom specifications, clear the parameter and configure the queue properties. Queue attributes are applicable if there is no storage block placed outside a component.
For more information, see Specify Queue Properties for Message Interface.
Dependencies
To enable this parameter for an element, set the Data
mode of the element to message
.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | MessageQueueUseDefaultAttributes |
Values: | "on" (default) | "off" |
Example: set_param("mymodel/InBus.message1",MessageQueueUseDefaultAttributes="off")
Specify the number of messages elements the queue can store.
Dependencies
To enable this parameter for an element, set the Data
mode of the element to message
.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | MessageQueueCapacity |
Values: | "1" (default) | scalar in quotes |
Data Types: | char | string |
Example: set_param("mymodel/InBus.message1",MessageQueueCapacity="10")
Choose one of these queue types:
FIFO
— First-in-first-outLIFO
— Last-in-first-out
Dependencies
To enable this parameter for an element, set the Data mode of
the element to message
.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | MessageQueueType |
Values: | "LIFO" (default) | "FIFO" |
Example: set_param("mymodel/InBus.message1",MessageQueueType="FIFO")
Select this parameter to choose between two queue overwriting policies.
If you select the parameter, an incoming message element overwrites the oldest message if the queue is full.
If you clear the parameter, the block does not accept new messages if the queue is full.
Dependencies
To enable this parameter for an element, set the Data
mode of the element to message
.
Programmatic Use
To programmatically set the attribute value for an element, use the set_param
function. Specify the element as the model name or subsystem block
path, a forward slash, and the port name or bus element path. For a bus element port, the
bus element path provides the hierarchy from the top-level bus to the target element,
separating each name in the hierarchy with a dot.
Parameter: | MessageQueueOverwriting |
Values: | "on" (default) | "off" |
Example: set_param("mymodel/InBus.message1",MessageQueueOverwriting="off")
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Alternative Configurations
The Bus Element In block differs from the In Bus Element block by name only.
Libraries:
Simulink /
Signal Routing
HDL Coder /
Signal Routing
Tips
When the port receives a bus with many bus elements, filter the displayed bus elements by entering a search term in the Filter box. Do not enclose the search term in quotation marks. The filter does a partial string search and supports regular expressions. Regular expressions let you filter based on whether the input elements match a pattern. For example, to display all elements whose names end with a lowercase
t
, entert$
in the Filter box. For more information, see Regular Expressions.To change the background color of an In Bus Element block, click
and select a standard color or specify a custom color. Alternatively, use the
BackgroundColor
block property. For more information, see Programmatically Specify Block Parameters and Properties.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
This block can be used to simplify subsystem bus interfaces when you use the block in subsystems that generate HDL code, but it is not included in the hardware implementation.
To learn more about using buses for HDL code generation, see Buses (HDL Coder) and Use Buses to Improve Readability of Model and Generate HDL Code (HDL Coder).
This block supports code generation for Simulink.ValueType
object. For
more information about value types, see Specify Common Set of Signal Properties as Value Type.
This block supports these data types for HDL code generation:
Input Port | Dimension | Fixed-Point | Floating-Point | Built-in Integers | Boolean | Complex Signal |
---|---|---|---|---|---|---|
Port_1 | Scalar Vector Matrix | Yes | Half Single Double | Yes | Yes | Yes |
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
Version History
Introduced in R2017aYou can now specify port, signal, and execution attributes more easily.
To toggle the display of port, signal, and execution attributes, click
. Port, signal, and execution attributes now appear on tabs. The
button replaces the buttons that appear when you pause on a bus, signal, or message name in a previous release.
When you specify execution attributes, a parenthetical now appears next to the name of the corresponding bus, signal, or message. To display the specified attributes, click
.
To edit the port name, double-click the name of the top-level bus, signal, or message. Alternatively, on the Port tab, specify Port name.
To change block colors, click
and select a standard color or specify a custom color.
To create a
Simulink.Bus
object using the Type Editor, on the Signal tab, click.
Dims mode is now named Dimensions mode.
You can now propagate element names from In Bus Element blocks. For
example, for an In Bus Element block labeled
InBus.nonconstant.chirp
, the propagated name is
chirp
.
For more information, see Signal Label Propagation.
When you press Ctrl and drag an In Bus Element block to a new location, you receive clearer options:
New Port — Create a port.
New Element — Add an element to the port.
Duplicate — Create a duplicate In Bus Element block.
In previous releases, you receive two options:
Create New Port — Create a port.
Use Existing Port — Create a duplicate In Bus Element block.
These actions now consistently create a port:
Double-click the canvas. Then, start typing
In Bus Element
, and select the block from the menu.Copy and paste an In Bus Element block.
In previous releases, these actions create a port, add an element to a port, or duplicate a block.
At both subsystem and model interfaces, you can specify the elements of an input
bus without In Bus Element blocks to represent each element or a
Simulink.Bus
object to define the bus hierarchy. Previously,
only In Bus Element blocks at model interfaces supported this
functionality.
To add the elements, click the button arrow. Then, select Add element
without block.
The Property Inspector supports In Bus Element and Out Bus Element blocks.
Warning and error messages for In Bus Element and Out Bus Element blocks now link to the corresponding block in the block diagram, helping you quickly find the source of the warning or error. In previous releases, warning and error messages refer to a hidden block and do not provide a link.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)