You can display bus information using multiple approaches.
要显示总线是虚拟的还是非虚拟的,请更新或模拟模型。虚拟总线出现为三条实线() and a nonvirtual bus appears as two solid lines on either side of a dashed line (
).
To interactively display the hierarchy of a bus, seeDisplay Bus Hierarchy.
To interactively display the value of bus elements at a port, seeDisplay Value of Bus Elements.
To programmatically display the virtuality and hierarchy of a bus, see以编程方式获得总线层次结构和虚拟性.
To interactively display bus hierarchy:
Click a signal line.
On theSignaltab, select信号层次结构.
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 namedmain_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.
Note
To produce accurate results at edit time in the Signal Hierarchy Viewer, your model must compile successfully.
To filter the displayed signals, click theOptionsbuttonon the right side of theFilter by nameedit box.
To use MATLAB®regular expressions for filtering signal names, select使正则表达式. For example, to display all signals whose names end with a lowercaser
(and their immediate parents), enterr $
在里面Filter by nameedit box. For more information, seeRegular Expressions.
To display a flat list of the filtered results, selectShow 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 theSignaltab, selectOutput 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 inModelBus
.
For more information, seeDisplay Value for a Specific Port.
To programmatically get the hierarchy and virtuality of a bus in a compiled model, query these parameters with theget_param
command:
'SignalHierarchy'
— If the signal is a bus, returns the name and hierarchy of the signals in the bus.
“编译”
- 对于一个模型“编译”
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 themodel
function to put the model in the“编译”
phase.
For example, open and simulate thebusdemo
model.
open_system('busdemo') sim('busdemo');
获取所需的公交信息的端口的手柄。
ph = get_param(['busdemo/Bus Creator'],“ Porthandles”);
Get the signal hierarchy at the port.
sh = get_param(ph.Outport,'SignalHierarchy')
sh =带字段的结构:信号名称:'main_bus'busObject:''儿童:[2×1 struct]
Get the compiled bus type at the port while the model is compiling.
busdemo([],[],[],,“编译”); bt = get_param(ph.Outport,“编译”)
bt ='virtual_bus'
Terminate compilation.
busdemo([],[],[],,'term');