Documentation

复合信号的类型

为了降低模型中的视觉复杂性,您可以将信号组合为复合信号。复合信号包含的信号称为元素。Elements retain their separate identities, which let you extract them from the composite signal.

您可以根据复合信号类型访问名称或索引的复合信号元素。

  • Index-based composite signals are flat, regardless of whether you create them in stages. They require that all input signals have the same data type.

  • Name-based composite signals allow for signal hierarchy. They are generically calledbuses

    Note

    A Simulink®公共汽车类似于一束由领带包裹固定在一起的电线。Si金宝appmulink总线不类似于硬件总线,例如计算机硬件体系结构中的总线。

    Not all blocks can accept buses and some blocks implicitly convert buses to vectors. To learn which blocks support which types of buses, see具有公共汽车的块。To learn how to identify implicit bus-to-vector conversions, seeManage Bus-to-Vector Conversions

When you group signals into a composite signal, you can decide whether they affect simulation and code generation.

  • Avirtualcomposite signal simplifies the visual appearance of a model by combining two or more signal lines into one line. It does not group the signals in any functional sense and, therefore, does not affect simulation or code generation.

  • Anonvirtualcomposite signal visually and functionally groups signals, affecting both simulation and code generation.

Models can use a combination of these composite signal types.

Composite Signal Feature Index-Based Access 基于名称的访问
Visual Grouping

MuxSignal

虚拟巴士

Functional Grouping

Concatenated Signal

非虚拟巴士

You can identify composite signal types by their line style.

Line Style 复合信号类型
虚拟巴士
Nonvirtual bus
Nonscalar信号时Nonscalar Signalsinformation overlay is enabled (includes index-based composite signals)
基于索引的复合信号,包含非虚拟巴士

虚拟巴士

该模型显示了一个包含信号的虚拟总线a,b, 和c

公共汽车创建者block creates a virtual bus within a subsystem or model. TheBus Selectorblock extracts elements of the bus within a subsystem or model by specifying element names.

This model shows an equivalent virtual bus passing through a subsystem boundary.

Out Bus Element块在子系统或模型接口处创建虚拟总线。In Bus Element通过指定元素名称,块提取了子系统或模型接口处的总线的指定元素。

您可以使用虚拟巴士来:

  • 包含具有不同样本率的总线元素。

  • Cross model reference boundaries, if the referenced model only uses a few of the bus elements.

使用虚拟总线更简单,并且比使用非虚拟总线更有效。通过直接访问元素,在模拟和生成的代码中,虚拟总线的执行速度比非虚拟总线更快。即使虚拟总线与测试点关联,虚拟总线的元素也会出现在生成的代码中。

To specify and validate the properties of a virtual bus, you can specify aSimulink.Bus目的。

一些建模功能需要非虚拟巴士,例如MATLAB功能块和状态流®charts.

非虚拟巴士

该模型显示了包含信号的非虚拟巴士a,b, 和c

公共汽车创建者块在子系统或模型中创建非虚拟总线。这Bus Selectorblock extracts elements of the bus within a subsystem or model by specifying element names.

For nonvirtual buses at subsystem or model interfaces, use外港企业块。

You can use nonvirtual buses to:

  • 显示和日志巴士信号与Scopeblock.

  • Construct an array of buses.

  • Have bus data crossMATLAB功能块或状态流图边界。

  • 通过S功能与外部代码接口。

  • 包装总线数据作为生成的C代码中的结构。

ASimulink.Busobject must define the bus you want to make nonvirtual. The bus object specifies only the architectural properties of a bus. For example, a bus object can specify element names, hierarchy, order, and data types. A bus object does not specify the values of the signals in a bus. For more information, seeSpecify Bus Properties with Bus Objects

Since a virtual bus can specify a bus object, a bus becomes nonvirtual when you also select the作为非虚拟巴士的输出parameter.

即使关联的总线对象指定继承的样本时间,非虚拟总线的所有元素也必须使用相同的示例时间。您可以使用Rate Transitionblock to change the sample time of an individual signal or of all signals in a bus.

总线的类型可以在生成代码的效率,大小和可读性上产生重大影响。生成的代码代表非虚拟总线作为结构。该结构有助于追踪模型和代码之间的对应关系。为非虚拟巴士生成代码可能会导致多个公交车的副本。如果您打算为使用总线的模型生成代码,请参见Generate Efficient Code for Bus Signals(金宝appSimulink编码器)。有关生成代码中虚拟和非虚拟总线之间差异的示例,请参见Generate Code for Buses

Concatenated Signal

该模型显示了一个并排放置输入矩阵的串联信号。

Matrix Concatenate块创建串联信号。元素可以是向量或矩阵,具体取决于您如何配置此块。这选择器块根据指定指标提取信号。提取的信号可以与输入信号分组不同。

您可以在数学操作中使用串联信号。

矢量联合或者Matrix Concatenate块,信号必须具有相同的数据类型。当数据类型是总线对象时,输入必须是非虚拟总线。

Concatenated nonvirtual buses are also known as an一系列公共汽车。在一系列总线中,所有元素都是使用相同总线对象指定属性的非虚拟总线。一系列公共汽车等同于MATLAB中的一系列结构®。您可以使用n array of buses to model a multichannel system. While all the channels have the same properties, each of the channels may have a different value.

在此模型中矢量联合街区创建了一系列公共汽车。

有关公共汽车阵列的更多信息,请参阅将公交车结合成一系列公共汽车

MuxSignal

This model shows a mux signal that places the three input signals side by side.

Muxblock creates mux signals. TheDemuxBlock提取所有信号,这些信号可能与输入信号分组不同。有关示例,请参见使用Demux块提取矢量元素。这选择器块根据指定指标提取信号。提取的信号可以与输入信号分组不同。

您可以在使用普通连续矢量的任何地方使用MUX信号。例如,您可以在MUX信号上执行计算。计算会影响MUX信号中的每个构成值,就好像这些值存在于连续矢量中一样。使用MUX信号在多个向量上执行计算,可以避免将单独值复制到连续存储的开销。您也可以使用Mux块创建函数调用向量。

输入信号Muxblock can be any combination of scalars, vectors, and mux signals, but they must have the same data type. The signals in the output mux signal appear in the same order as the input signals for theMuxblock. You can use multipleMuxblocks to create a mux signal in stages, but the result is flat as if you used a singleMuxblock.

相关话题