Add Bus to Vector blocks to convert virtual bus signals into vector signals
[
DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
')
[DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
', includeLibs
)
[DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
', includeLibs
, reportOnly
)
[
searches
a model, excluding any library blocks, for bus signals used implicitly
as vectors, and returns the results of the search. Before executing
this function, you must do the following:DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
')
Set Simulation > Model Configuration
Parameters > Diagnostics > Connectivity > Buses > Mux
blocks used to create bus signals to error
,
or equivalently, execute set_param (
.model
,
'StrictBusMsg', 'ErrorLevel1')
Ensure that the model compiles without error.
Save the model.
[
is
equivalent to DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
', includeLibs
)[
if DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector(model
)includeLibs
is false
.
If includeLibs
is true
,
the function searches library blocks rather than excluding them.
[
is
equivalent to DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector('model
', includeLibs
, reportOnly
)[
if DstBlocks
, BusToVectorBlocks
]
= Simulink.BlockDiagram.addBusToVector(model
, includeLibs
)reportOnly
is true
.
If reportOnly
is false
,
the function inserts a Bus to Vector block
into each bus that is used as a vector in any block that it searches.
The search excludes or includes library blocks as specified by includeLibs
.
The insertion replaces the implicit use of a bus as a vector with
an explicit conversion of the bus to a vector. The signal's source
and destination blocks are unchanged by this insertion.
If Simulink.BlockDiagram.addBusToVector
adds
Bus to Vector blocks to the model or any library, the function permanently
changes the saved copy of the diagram. Be sure to back up the model
and any libraries before calling the function with reportOnly
specified
as false
.
If Simulink.BlockDiagram.addBusToVector
changes
a library block, the change affects every instance of that block in
every Simulink^{®} model that uses the library. To preview the effects
of the change on blocks in all models, call Simulink.BlockDiagram.addBusToVector
with includeLibs
= true
and reportOnly
= true
,
then examine the information returned in DstBlocks
.

Model name or handle 

Boolean specifying whether to search library blocks ( Default: 

Boolean specifying whether to change the model ( Default: 

An array of structures that contain information about blocks that are connected to buses but treat the buses as vectors. If no such blocks exist the array has 0 length. Each structure in the array contains the following fields:
 

If 
You can eliminate warnings and errors about virtual buses used
as muxes by using Simulink.BlockDiagram.addBustoVector
to
insert a Bus to Vector block into any virtual bus signal that is used
as a mux. For additional information, see Prevent Bus and Mux Mixtures.
The following model simulates correctly, but the input to the Gain block is a bus, while the output is a vector. Thus the Gain block uses a block as a vector.
If the model shown is open as the current model, you can eliminate the implicit conversion with the following command:
Simulink.BlockDiagram.addBusToVector(gcs, false, false)
Rebuilding and simulating the model then gives this result:
The Gain block no longer implicitly converts the bus to a vector; the inserted Bus to Vector block performs the conversion explicitly. Note that the results of simulation are the same for both models. The Bus to Vector block is virtual, and never affects simulation results, code generation, or performance.
Bus Assignment  Bus Creator  Bus Selector  Bus to Vector  Simulink.Bus
 Simulink.Bus.cellToObject
 Simulink.Bus.createObject
 Simulink.Bus.objectToCell
 Simulink.Bus.save
 Simulink.BusElement