Main Content

Out Bus Element

Specify output of external port

  • Out Bus Element block

Libraries:
Simulink / Ports & Subsystems
Simulink / Sinks
HDL Coder / Ports & Subsystems
HDL Coder / Sinks

Alternative Configurations of Out Bus Element Block:
Bus Element Out

Description

The Out Bus Element block provides a bus, signal, or message as the output of an external port.

To group multiple buses, signals, or messages into an output bus, use multiple Out Bus Element blocks that correspond with the same port. The Out Bus Element blocks combine the functionality of a Bus Creator block and an Outport block. All Out Bus Element blocks that correspond with the same port share a dialog box.

For interfaces that include buses composed of many bus elements, Out 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 Creator and From block configuration.

To convert an interface to use Out Bus Element blocks, see Simplify Subsystem and Model Interfaces with Bus Element Ports.

The Out Bus Element block does not support mixing message and signal elements as inputs.

When you save output data to the workspace or a file, bus data defined by groups of root-level Out Bus Element blocks are logged along with root-level Outport block data.

Examples

expand all

In a model component, each output bus element port is represented by one or more Out Bus Element blocks.

Open the example model named CreateOutputBusElementPort.

How you add an input bus element port depends on whether you are in the model component or its parent.

To add an output bus element port to the currently open subsystem or model, add an Out Bus Element port to the top level of the model. For example, double-click the canvas and start typing the block name. Then, select the Out Bus Element block.

To add an output bus element port to a Subsystem or Model block in the current component, click the edge of the block and select Create out bus port. For example, add an output bus element port to the Subsystem block.

To open the subsystem, double-click the Subsystem block.

The subsystem contains a default Out Bus Element block that corresponds to the output port you created on the Subsystem block. The block label uses default values for its two interactive text fields: the port name (OutBus) and the bus element (signal1).

To create another output bus element port from inside a model component, hold Ctrl while you drag an existing Out Bus Element block to a new location. Upon releasing the pointer, click Create New Port.

An Out Bus Element block with a unique port name appears.

In this example, the new port is named OutBus1.

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 to the desired name for the port.

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.

When you have only one Out Bus Element block for a port, you can pass the block input to the output port without nesting it in a bus.

Open and compile the example model named SignalOutputBusPort. 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 Subsystem block has an output port that passes a bus to a Scope block.

To view the Out Bus Element block that corresponds with the output port, open the subsystem.

In the subsystem, a Sine Wave block connects to an Out Bus Element block. Based on the block label, OutBus.signal1, the port output is a bus that contains an element named signal1. The dot in the block label indicates the bus hierarchy.

To pass the signal to the output port without nesting it in a bus, delete the second text field from the block label. For example, click signal1 to edit the text field.

Then, delete signal1. To commit the change, click elsewhere on the canvas.

To change the name of the port associated with the block, edit the first text field in the block label. For example, click OutBus to edit the text field.

Then, delete OutBus and enter SineWave. Ignore the placeholder text that shows where you can enter an element name.

Alternatively, set the Port name block parameter to the desired name for the port.

Navigate up to the parent model and recompile.

The output port of the Subsystem block now passes a signal rather than a bus to the Scope block.

To specify multiple elements for an output port, use an Out Bus Element block for each element that you want in the output. All element names associated with the same output port must be unique. The software does not support overlapping writes to the same port.

Open the example model named SpecifyOutputElements.

An Out Bus Element block writes to an element named signal1 of a port named OutBus.

To rename an element, edit the second text field in the block label. For example, double-click signal1 and enter constant*5.

Open the Property Inspector. Then, select the Out Bus Element block. Alternatively, double-click the block to open a dialog box.

The signal that the block selects is highlighted.

To add another element to the port, click Add a new signal.

An Out Bus Element block labeled OutBus.signal1 appears in the block diagram.

In the Property Inspector or dialog box, double-click the name signal1 and enter sine+chirp.

The corresponding block label updates.

Connect the new Out Bus Element block to the unconnected port of the Sum block.

The default Out Bus Element block nests the output element in a bus. When the output port has many elements, organize the elements in nested buses within the output bus.

Open the example model named OutputBusPortHierarchy, which contains three Out Bus Element blocks.

Each dot in an Out Bus Element block label indicates a new level of hierarchy. To nest an element under another bus in the output bus, edit the second text field of the corresponding block label and add a dot after each nested bus in the hierarchy.

For example, click constant*5. Then, change it to NestedBus.constant*5.

This label creates an intermediate bus named NestedBus that contains constant*5.

To add elements to the new bus, you can similarly edit other block labels. Alternatively, double-click an Out Bus Element block or open the Property Inspector and select an Out Bus Element block.

To move elements within the output bus, select the elements to move and drag them to a new location. For example, drag the signal named sine+chirp into the nested bus.

The block label updates to indicate the new hierarchy.

To add a nested bus and leaf element to the output bus, along with the corresponding Out Bus Element block, click Add a new sub-bus.

The nested bus and element use default names.

Use compact labels and block colors to customize the appearance of In Bus Element and Out Bus Element blocks.

Open the example model named BusElementPortBlocks.

The model contains:

  • In Bus Element blocks that represent two unique bus element ports named Inbus and pulse

  • 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 Set color and select a color from the menu.

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 Set color and select a different color from the menu.

The blocks related to the nested bus use the chosen color.

Ports

Input

expand all

Connect a bus, signal, or message to pass to the corresponding external output port of the parent subsystem or model.

When multiple Out Bus Element blocks are associated with the same external port, the input to this block is an element of the bus at the output port. The second text field in the block label specifies the element name.

When one Out Bus Element block is associated with the external port, the input to this block is passed directly to the output port or nested in a bus at the output port. To pass the input of the block to the output port without nesting it in a bus, delete the text from the second text field in the block label.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Boolean | fixed point | enumerated | bus
Complex Number Support: Yes

Parameters

expand all

To interactively edit the parameters of the block, the corresponding port, and the elements at the port, double-click the block or open the Property Inspector and select the block.

Specify a port name that is not already in use by another block or port. The name appears on the parent Subsystem or Model block. The name also appears next to the block. Multiple blocks can access the same port.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: PortName
Values: 'OutBus' (default) | port name in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/PortBlock','PortName','myBus')

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')

Specify the block background color. This specification sets the color of blocks associated with selected elements, or of all blocks associated with the port if you do not select any elements.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: BackgroundColor
Values: 'black' (default) | 'white | 'red' | 'green' | 'blue' | 'cyan' | 'magenta' | 'yellow' | 'gray' | 'lightBlue' | 'orange' | 'darkGreen' | '[r,g,b]' where r, g, and b, are the red, green, blue values of the color in the range 0.0 to 1.0

Example: set_param('mymodel/Subsystem1/PortBlock','BackgroundColor','magenta')

Specify a search term to use for filtering a long list of bus elements. Do not enclose the search term in quotation marks. The filter does a partial string search and supports regular expressions. To use a regular expression character as a literal, include an escape character (\). For example, to use a question mark, type sig\?1.

Attributes

To specify attributes, such as data type, pause on the name of a bus, signal, or message. Then, click the pencil button that appears.

Pencil button next to bus name

When you specify attributes, they appear next to the name of the bus, signal, or message. Click an attribute summary to edit the attributes of the bus, signal, or message.

Attribute summaries next to bus and bus element names

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 or uint8. See Data Types Supported by Simulink.

  • Fixed-point data type — Use the fixdt function. For example, specify fixdt(1,16,0).

  • Enumerated data type — Use the name of the type preceded by Enum:. For example, specify Enum: myEnumType.

  • Bus data type — Use the name of the Simulink.Bus object preceded by Bus:. For example, specify Bus: myBusObject.

  • Value type — Use the name of the Simulink.ValueType object preceded by ValueType:. For example, specify ValueType: windVelocity.

  • Custom data type — Use a MATLAB expression that specifies the type. For example, you can specify a Simulink.NumericType object whose DataTypeMode 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 a Simulink.ValueType object with a Simulink.Bus object data type, the Property Inspector and block dialog box display the elements defined by the corresponding Simulink.BusElement objects.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

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>'

Example: set_param('mymodel/Subsystem1/myBus.signal1','OutDataTypeStr','int32')

Specify the data mode of the output element.

  • inherit — Output element inherits its data mode.

  • signal — Output element must be a signal or a bus that contains signals.

  • message — Output element must be a message or a bus that contains messages.

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, specifying the element as the block path of the model component with the element label.

Parameter: DataMode
Values: 'inherit' (default) | 'signal' | 'message'

Example: set_param('mymodel/OutBus','DataMode','signal')

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, specifying the element as the block path of the model component with the element label.

Parameter: BusVirtuality
Values: 'inherit' (default) | 'virtual' | 'nonvirtual'

Example: set_param('mymodel/Subsystem1/myBus.nestedBus','BusVirtuality','nonvirtual')

Specify the dimensions of a signal.

  • -1 — The signal can have any dimensions.

  • N — The signal must be a vector of size N.

  • [R C] — The signal must be a matrix having R rows and C columns.

Dependencies

  • When Data type specifies a Simulink.Bus object, the software sets this parameter to 1. The software uses the dimensions specified by the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: PortDimensions
Values: '-1' (default) | integer in quotes | 1-by-2 vector of integers in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/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 to Inherit. The software uses the dimensions modes specified by the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

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 to inherit. The software uses the units specified by the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: Unit
Values: 'inherit' (default) | unit supported by Simulink software in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/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 to auto. The software uses the complexity specified by the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: SignalType
Values: 'auto' (default) | 'real' | 'complex'

Example: set_param('mymodel/Subsystem1/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 the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

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 the Simulink.BusElement objects in the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

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 the Simulink.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 the Simulink.ValueType object instead.

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: Description
Values: '' (default) | description in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/myBus.signal1','Description','This signal is used by...')

Since R2023a

Specify the name of the output bus, signal, or message in the parent subsystem or model. The name appears as a label on the line.

To display propagated labels for individual lines or all lines in a model, see Display Propagated Signal Labels.

Dependencies

  • To enable this parameter:

    • The block must be at the top level of a model.

    • The element must be the top-level bus, signal, or message.

  • When Data type specifies a Simulink.Bus object, the software sets this parameter to "" (empty).

Programmatic Use

To programmatically set the attribute value for an element, use the set_param function, specifying the element as the block path of the model component with the element label.

Parameter: OutputName
Values: "" (default) | output name in quotes
Data Types: char | string

Example: set_param('mymodel/OutBus','OutputName','model-output')

Execution Attributes

To specify execution attributes, such as sample time, pause on the name of a bus, signal, or message. Then, click Specify execution attributes .

Mouse pointer paused on Specify execution attributes button next to bus name.

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, specifying the element as the block path of the model component with the element label.

Parameter: SampleTime
Values: '-1' (default) | scalar in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/myBus.signal1','SampleTime','0.01')

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Alternative Configurations

expand all

The Bus Element Out block differs from the Out Bus Element block by name only.

Libraries:
Simulink / Signal Routing
HDL Coder / Signal Routing

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2017a

expand all