| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
[DstBlocks, BusToVectorBlocks]
= Simulink.BlockDiagram.addBusToVector(model)
[DstBlocks, BusToVectorBlocks]
= Simulink.BlockDiagram.addBusToVector(model, includeLibs)
[DstBlocks, BusToVectorBlocks]
= Simulink.BlockDiagram.addBusToVector(model, includeLibs, reportOnly)
[DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model) 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:
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.
[DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model, includeLibs) is equivalent to [DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model) if includeLibs is false.
If includeLibs is true, the function searches library blocks rather than excluding them.
[DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model, includeLibs, reportOnly) is equivalent to [DstBlocks, BusToVectorBlocks] = Simulink.BlockDiagram.addBusToVector(model, includeLibs) if 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.
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.
model |
Model name or handle |
includeLibs |
Boolean specifying whether to search library blocks (true) or only the top-level model (false). Default: false |
reportOnly |
Boolean specifying whether to change the model (false) or just generate a report (true). Default: true |
DstBlocks |
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:
| ||||||
BusToVectorBlocks |
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 ([]). |
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

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |