Simulink® provides several techniques for combining signals into a composite signal. For a comparison of techniques, see Composite Signal Techniques.
An array of nonvirtual buses is an array whose elements are buses. Each bus object has the same signal name, hierarchy, and attributes for its bus elements.
An example of using an array of buses is to model a multi-channel system, such as a communications system. You can model all the channels using the same bus object, although each of the channels could have a different value.
To use an arrays of buses:
Use a bus object as a data type (see Specify a Bus Object Data Type).
Specify dimensions for the bus and bus elements.
For an example of a model that uses an array of buses, open
sldemo_bus_arrays model. In this example, the nonvirtual
bus input signals connect to a Vector Concatenate or Matrix
Concatenate block that creates an array of bus signals. Here
is the diagram after you update it:
The model uses the array of buses with:
An Assignment block, to assign a bus in the array
A For Each Subsystem block, to perform iterative processing over each bus in the array
A Memory block, to output the array of buses input from the previous time step
Use an array of buses to:
Represent structured data compactly.
Reduce model complexity.
Reduce maintenance by centralizing algorithms used for processing multiple buses.
Streamline iterative processing of multiple buses of the same type, for example, by using a For Each Subsystem with the array of buses.
Simplify changing the number of buses, without your having to restructure the rest of the model or make updates in multiple places in the model.
Use built-in blocks, such as the Assignment or Selector blocks, to manipulate arrays of buses just like arrays of any other type. Using a array of buses avoids the need for you to create custom S-functions to manage packing and unpacking structure signals.
Use the combined bus data across subsystem boundaries, model reference boundaries, and into or out of a MATLAB Function block.
Keep all the logic in the Simulink model, rather than splitting the logic between C code and the Simulink model. This approach supports integrated consistency and correctness checking, maintaining metadata in the model, and avoids the need to manage model components in two different environments.
Generate code that has an array of C structures, which
you can integrate with legacy C code that uses arrays of structures.
This approach simplifies indexing into an array for Simulink computations,
for loop on indexed structures.
For information about the kinds of buses that you can combine into an array of buses, see Bus Requirements.
To define an array of buses, use a Concatenate block. The table describes the array of buses input requirements and output for each of the Vector Concatenate and the Matrix Concatenate versions of the Concatenate block.
|Block||Bus Signal Input Requirement||Output|
Vectors, row vectors, or columns vectors
If any of the inputs are row or column vectors, output is a row or column vector.
Signals of any dimensionality (scalars, vectors, and matrices)
Trailing dimensions are assumed to be 1 for lower dimensionality inputs.
Concatenation is on the dimension that you specify with the Concatenate dimension parameter.
Do not use a Mux block or a Bus Creator block to define an array of buses. Instead, use a Bus Creator block to create scalar bus signals.
Define one bus object for all of the buses that you want to combine into an array of buses. For information about defining bus objects, see Create Bus Objects.
sldemo_bus_arrays_busobject bus object,
which both of the Bus Creator blocks use for the input bus signals
Scalar Bus) for the array of buses.
sldemo_bus_arrays_busobject model uses
a Vector Concatenate block, because the inputs are scalars.
Set the Number of inputs parameter to be the number of buses that you want to be in the array of buses.
The block icon displays the number of input ports that you specify.
Set the Mode parameter to match the type of the input bus data.
sldemo_bus_arrays model, the input
bus data is scalar, so the Mode setting is
If you use a Matrix Concatenation block, set the Concatenate dimension parameter to specify the output dimension along which to concatenate the input arrays. Enter one of the following values:
1 — concatenate input arrays
2 — concatenate input arrays
A higher dimension than 2 — perform multidimensional concatenation on the inputs
Connect to the Concatenate block all the buses that you want to be in the array of buses.