Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Correct Buses Used as Vectors

Three Approaches

The three approaches that you can use to correct bus signals used as vectors (muxes) to avoid an error are:

Generally, using the Model Advisor is the most efficient approach.

Use the Model Advisor

  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 bus signals 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.

Explicitly Add Bus to Vector Blocks

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

  • To convert the bus to a vector explicitly, insert the Bus to Vector block into any bus used implicitly as a vector.

  • Use the Simulink.BlockDiagram.addBusToVector function, which automatically inserts Bus to Vector blocks wherever needed.

For example, this model treats a bus signal as a vector signal by using the bus as an input to a Gain block. The Scope block shows the simulation results.

This figure shows the same model, rebuilt after inserting a Bus to Vector block after the Bus Creator block.

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

Reorganize the Model

You can replace blocks manually. Change the sources for a block that require vector inputs to avoid feeding a bus signal into a block that requires vector input.

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

To provide the required vector signal for the Gain block, change the Bus Creator block to a Mux block.

Challenges with reorganizing the model manually include:

  • It can be difficult to identify all the occurrences in a model. (The Model Advisor check identifies all occurrences in the model and helps you to correct them.)

  • 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.

Bus to Vector Block Compatibility Issues

If you use Save As for a model in a version of the Simulink product before R2007a, Simulink replaces each Bus to Vector block with a null subsystem that outputs nothing. Before you can use the model, reconnect or otherwise correct each signal that used to contain a Bus to Vector block but now is interrupted by a null subsystem.

Related Topics

Was this topic helpful?