You can display bus information using multiple approaches.
To display whether a bus is virtual or nonvirtual, update or simulate the model. A virtual bus appears as three solid lines () and a nonvirtual bus appears as two solid lines on either side of a dashed line ().
To interactively display the hierarchy of a bus, see Display Bus Hierarchy.
To interactively display the value of bus elements at a port, see Display Value of Bus Elements.
To programmatically display the virtuality and hierarchy of a bus, see Programmatically Get Bus Hierarchy and Virtuality.
To interactively display bus hierarchy:
Click a signal line.
On the Signal tab, select Signal Hierarchy.
A Signal Hierarchy Viewer opens, showing the signal hierarchy for the selected signal.
For example, this Signal Hierarchy Viewer shows the signal hierarchy for a bus
Each Signal Hierarchy Viewer is associated with a specific model. If you edit a model while the associated Signal Hierarchy Viewer is open, the Signal Hierarchy Viewer reflects those updates.
To produce accurate results at edit time in the Signal Hierarchy Viewer, your model must compile successfully.
To filter the displayed signals, click the Options button on the right side of the Filter by name edit box.
To use MATLAB® regular expressions for filtering signal names, select
Enable regular expression. For example, to display
all signals whose names end with a lowercase
r (and their
immediate parents), enter
r$ in the Filter by
name edit box. For more information, see Regular Expressions.
To display a flat list of the filtered results, select Show filtered results as a flat list. The flat list uses dot notation to indicate the hierarchy of buses. This example shows a filtered set of nested buses.
To interactively display the values of bus elements at a port:
Click a signal line.
On the Signal tab, select Output Value Label.
Click the port value label, and select the signals you want to display.
For example, in this model, you can select which signals to display
from the signals that are contained in
For more information, see Display Value for a Specific Port.
To programmatically get the hierarchy and virtuality of a bus in a compiled model,
query these parameters with the
'SignalHierarchy' — If the signal is a bus,
returns the name and hierarchy of the signals in the bus.
'CompiledBusType' — For a model that is in the
'compile' phase, returns information about whether
the signal connected to a port is a bus and whether the signal is a virtual
or nonvirtual bus. Before you query the
parameter value, use the
model function to put the
model in the
For example, open and simulate the
Obtain the handle of the port for which you want bus information.
ph = get_param(['busdemo/Bus Creator'], 'PortHandles');
Get the signal hierarchy at the port.
sh = get_param(ph.Outport, 'SignalHierarchy')
sh = struct with fields: SignalName: 'main_bus' BusObject: '' Children: [2×1 struct]
Get the compiled bus type at the port while the model is compiling.
busdemo(,,,'compile'); bt = get_param(ph.Outport, 'CompiledBusType')
bt = 'VIRTUAL_BUS'