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.

Assign Signal Values to a Bus

To assign the values of a signal to bus element, you can use a Bus Assignment block. Use a Bus Assignment block to change bus element values without adding Bus Selector and Bus Creator blocks that select bus elements and reassemble them into a bus.

Connect to the Bus Assignment block ports:

  • The bus signal to which you want to assign the signal values

  • The signals whose values you want to assign to specified bus elements

Connect the bus signal to the first input port of the Bus Assignment block, and one or more signals to be assigned to the other ports. The Block Parameters dialog box lists the signals available for assignment in the bus. The bus can be virtual or nonvirtual. Select the elements to which you want to assign signal values. If you specify more than one signal to assign values to, the Bus Assignment block adds ports.

The signals that you assign values to can be nonbus or bus signals. The signals must match the attributes of the signals in the original bus.

Update a Bus Element

This simple example illustrates the mechanics of using the Bus Assignment block. In more complex models, using a Bus Assignment block simplifies updating a bus to reflect the processing that occurs in a separate component, such as a subsystem or referenced model. Here is the model after you simulate it.

Some key steps in constructing this model are:

  1. Connect two Constant blocks to a Bus Creator block. The value of signal a is 1, and the value of signal b is 2.

  2. Connect the Bus Creator output signal const_bus to the first port of a Bus Assignment block. The bus elements a and b are available to assign new values to them.

  3. Connect the Constant block output signal c to the second port of the Bus Assignment block.

  4. For the Bus Assignment block, in the Block Parameters dialog box Signals in the bus list, select the a signal and click Select>>.

  5. Use a Bus Selector to select signals a and b from the const_bus signal and connect those signals to Display blocks.

  6. Simulate the model. The Display blocks show that the value of signal a, which was 1 when the const_bus bus was created, is now 3, reflecting the assignment of the c signal from the Const3 block.

See Also


Related Topics