| Simulink® | ![]() |
[DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model) [DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model, includeLibs) [DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model, includeLibs, reportOnly)
Model name or handle
Boolean specifying whether to search library blocks. Default: false; the function does not search library blocks.
Boolean specifying whether to change the model or just generate a report. Default: true; the function just generates a report.
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:
A string specifying the path to the block to which the bus connects
An integer specifying the input port to which the bus connects
If the block is a library block instance, and includeLibs is true, the path to the source library block. Otherwise, LibPath is empty ([]).
If reportOnly is false, and model contains any buses used as vectors, a cell array containing the path to each Bus to Vector block that was added to the model. Otherwise, BusToVectorBlocks is empty ([]).
Simulink.BlockDiagram.addBusToVector reports whether a model contains any bus signals used implicitly as vectors, and optionally changes the model by inserting a Bus to Vector block into each such signal, replacing the implicit use with an explicit conversion. The report and any changes can be limited to the model itself, or can be extended to include any library block of which an instance appears in the model.
Before executing this function, you must do the following:
Set 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.
If includeLibs is false (the default), the function does not report on or change any blocks in libraries. If the argument is true, the function reports on and may change blocks in libraries.
If reportOnly is true (the default), the function does not change the model or any libraries, displays the number of buses used as vectors, and returns a report in DstBlocks.
If reportOnly is false, the function displays the number of buses used as vectors, returns a report in DstBlocks and BusToVectorBlocks, and inserts a Bus to Vector block into each bus that is used as a vector, in the model and optionally in any libraries. The signal's source and destination blocks are unchanged by this insertion.
Note 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. |
Caution 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. |
The Bus to Vector block is intended only for use in existing models to facilitate the elimination of implicit conversion of buses into vectors. New models and new parts of existing models should avoid implicitly using buses as vectors, and should not use Bus to Vector blocks for any purpose. See Avoiding Mux/Bus Mixtures for more information about using Simulink.BlockDiagram.addBusToVector.
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.
![]() | simulink | Simulink.BlockDiagram.copyContentsToSubSystem | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |