This topic describes how to use buses with Inport and Outport blocks in a model.
For information about using buses as inputs to, or outputs from, a referenced model, see Bus Data Crossing Model Reference Boundaries.
If you want a root level Inport of a model to produce a bus
signal, in the Inport block parameters dialog box, set Data
Bus: <object name> and
<object name> with the name of the
bus object name that defines the bus that the Inport produces. See Bus Objects for more information.
A root level Outport of a model can accept a virtual bus only if all elements of the bus have the same data type. The Outport block automatically unifies the bus to a vector having the same number of elements as the bus, and outputs that vector.
If you want a root level Outport of a model to accept a bus
signal that contains mixed types, in the Outport block parameters
dialog box, set Data type to
<object name> and replace
name> with the name of the bus object name that defines
the bus that the Inport produces. If the bus signal is virtual, it
will be converted to nonvirtual, as described in Automatic Bus Conversion. See Bus Objects more information.
By default, an Inport block is a virtual block and accepts a bus as input. However, an Inport block is nonvirtual if:
The Inport block is in a conditionally executed or atomic subsystem, or in a referenced model.
The bus or any of its elements are directly connected to the output of the subsystem or referenced model.
In such a case, the Inport block can accept a bus only if all elements of the bus have the same data type or the bus is a nonvirtual bus.
If the bus elements are of differing data types, attempting to simulate the model causes the Simulink® software to halt the simulation and display an error message. You can avoid this problem, without changing the semantics of your model, by inserting a Signal Conversion block between the Inport block and the Outport block to which it was originally connected.
For example, the following model, which includes an atomic subsystem, does not simulate.
Starting the simulation generates the following error messages:
Opening the subsystem reveals that in this model, the Inport
nonvirtual is nonvirtual because
it resides in an atomic subsystem and one of its bus elements (labeled
is directly connected to one of the subsystem's outputs. Further,
the bus (
bus1) connected to the subsystem's inputs
has elements of differing data types. As a result, you cannot simulate
To break the direct connection to the subsystem's output, insert
a Signal Conversion block. Set the Signal Conversion block Output parameter
Signal copy. Inserting the Signal Conversion
block enables the Simulink software to simulate the model.