Iteratively Process Nonvirtual Buses with Arrays of Buses
Update a model to use an array of buses when:
The model contains many subsystems that perform the same kind of processing.
The model has grown in complexity.
For example, compare the following modeling patterns.
In the original modeling pattern:
Three nonvirtual buses specify a
Simulink.Busobject data type named
Each of these nonvirtual buses connects to a Subsystem block.
The Subsystem blocks, named
ScalarAlgorithm3, have the same content.
The original modeling pattern is inefficient. To process each nonvirtual bus, the model
has copies of the subsystem that encapsulates the algorithm. To process another nonvirtual bus
with the same
BusObject data type, the model requires another copy of the
To convert the original modeling pattern to use an array of buses:
Identify the buses and associated algorithm that you want to convert.
The buses that you concatenate in an array of buses must be nonvirtual. If the buses are virtual and all their elements have the same sample time or inherit their sample time, convert the virtual buses to nonvirtual buses.
The nonvirtual buses cannot have variable-dimensioned and frame-based elements.
Use a Vector Concatenate block to group the nonvirtual buses into an array of buses.
Replace all identical copies of the subsystem with a for-each subsystem that encapsulates the algorithm.
Connect the array of buses to the for-each subsystem.
Configure the For Each Subsystem block to iterate over the input array of buses and concatenate the output.
The scalar algorithm within the for-each subsystem cannot have continuous states.
The array of buses lets you replace multiple identical subsystems with one subsystem that supports iterative processing.
For more information on creating arrays of buses, see Group Nonvirtual Buses in Arrays of Buses.