This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Correct Buses Used as Vectors

When a block that requires a vector input receives a bus input, the bus is implicitly treated as a vector. Configuring a model to avoid using buses as vectors:

  • Improves loop handling

  • Contributes to consistent edit and compile-time behavior

Correct Buses Using the Model Advisor

When correcting buses used as vectors, the Model Advisor generally provides the most efficient approach.

  1. In the Simulink® Editor, select Analysis > Model Advisor > Model Advisor.

  2. Select and run the Simulink Check bus signals treated as vectors check.

    The Model Advisor reports any cases of buses treated as vectors.

  3. Follow the Model Advisor suggestions for correcting errors reported by the check.

For additional information about using the Model Advisor, see Select and Run Model Advisor Checks.

Add Bus to Vector Blocks

To explicitly convert a bus to a mux (vector), add Bus to Vector blocks using one of these approaches:

  • Insert the Bus to Vector block into buses treated as vectors.

  • Use the Simulink.BlockDiagram.addBusToVector function, which automatically inserts Bus to Vector blocks where buses are treated as vectors.

For example, model ex_bus_to_vector treats buses as vectors by using the buses as inputs to Gain blocks.

This figure shows the same model with Bus to Vector blocks after the Bus Creator block.

The Scope block shows the simulation results.

The simulation results are the same in either case. The Bus to Vector block is virtual, and does not affect simulation results, code generation, or performance.

Reorganize the Model

To avoid feeding a bus into a block that requires a vector input, you can manually replace the source for a block that requires vector inputs.

For example, in model ex_bus_to_vector, the Gain block requires a vector signal. However, the input signal is a bus created by a Bus Creator block.

To provide the required vector signal for the Gain block, replace the Bus Creator block with a Mux block.

Reorganizing the model manually poses these challenges:

  • Identifying all occurrences in a model can be difficult.

  • Dealing with many occurrences in a model is time-consuming and error-prone.

  • Reorganizing the model to address this issue can interfere with other aspects of the model.

Identify Implicit Bus-to-Vector Conversions

To identify buses treated as vectors:

  • Use the Model Advisor Check bus signals treated as vectors check.

  • Use the Simulink.BlockDiagram.addBusToVector function.

  • Set configuration parameter Bus signal treated as vector to warning or error. The default setting for Bus signal treated as vector is none, which generates no warning or error message when a block implicitly converts a bus to a vector during simulation.

See Also

Blocks

Related Topics