Viewing information about bus signals can help you during model creation, debugging, and analysis. To view information about buses, you can use different approaches, depending on your modeling task:
To display bus signals in a bus hierarchy interactively, use the Signal Hierarchy Viewer.
To display the value of a specific port or port values for a block before simulation, right click on the signal and select Show Value Label of Selected Port. For details, see Port Value Display.
To display at the MATLAB® command line the type
and hierarchy of a bus signal use the
For details, see CompiledBusType and SignalHierarchy Parameters.
You can use the Signal Hierarchy Viewer to display information about a signal. To display the bus hierarchy:
Right-click a signal line.
Select the Signal Hierarchy option. The Signal Hierarchy Viewer dialog box appears.
For example, open the
main_bus signal (output signal
for the Bus Creator block), and select Signal
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.
You can also open the Signal Hierarchy Viewer in the Simulink® Editor.
Select Diagram > Signals & Ports > Signal Hierarchy.
Select a signal.
To produce accurate results at edit time, the Signal Hierarchy Viewer requires that the model compiles successfully.
To filter the displayed signals, click the Options button on the right-hand 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
their immediate parents), enter
r$ in the Filter
by name edit box. For details, see Regular Expressions (MATLAB).
To use a flat list format to display the list of filtered signals, based on the search text in the Filter by name edit box, select Show filtered results as a flat list. The flat list format uses dot notation to reflect the hierarchy of bus signals. This example shows a flat list format for a filtered set of nested bus signals.
To display the value of a specific port or port values for a block before simulation, right click on the signal and select Show Value Label of Selected Port.
For bus signals, the Show Value Label of Selected
Port option opens a dialog box where you can select
from all signals in the bus. For example, in this model, you can see
the dialog box for all signals that are contained in
For more information about port value display, see Display Value for a Specific Port.
To get information about the type and hierarchy of a bus signal in a compiled
model, use these parameters with the
CompiledBusType — For a compiled model, returns
information about whether the signal connected to a port is a bus and
whether the signal is a virtual or nonvirtual bus.
SignalHierarchy — If the signal is a bus,
returns the name and hierarchy of the signals in the bus.
Before you use these commands, for
CompiledBusType, update the
diagram or simulate the model.
For example, open and simulate the
This code illustrates how you can use the
mdl = 'busdemo'; open_system(mdl) % Obtain the handle a port ph = get_param([mdl '/Bus Creator'], 'PortHandles'); % SignalHierarchy is available at edit time sh = get_param(ph.Outport, 'SignalHierarchy') % Compile the model busdemo(,,,'compile'); bt = get_param(ph.Outport, 'CompiledBusType') % Terminate the model busdemo(,,,'term');