Replace Values of Bus Elements
To assign the value of an input to a bus element, you can use aBus Assignment块。Use aBus Assignmentblock to change bus element values without addingBus SelectorandBus Creatorblocks that select bus elements and reassemble them into a bus.
Connect to theBus Assignmentblock ports:
公共汽车去which you want to assign the values
The lines whose values you want to assign to specified bus elements
Connect the bus to the first input port of theBus Assignmentblock, and one or more lines with values to be assigned to the other ports. The Block Parameters dialog box lists the elements available for assignment in the bus. The bus can be virtual or nonvirtual. Select the elements to which you want to assign values. If you specify more than one element to assign values to, theBus Assignmentblock adds ports.
The elements that you assign values to can be nonbus or bus signals. The new values must match the attributes of the elements in the original bus.
Update a Bus Element
This simple example illustrates the mechanics of using theBus Assignment块。在更复杂的模型,使用Bus Assignmentblock 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:
Connect twoConstantblocks to aBus Creator块。The value of signal
a
is 1, and the value of signalb
is 2.Connect theBus Creatoroutput bus
const_bus
to the first port of aBus Assignment块。The bus elementsa
andb
are available to assign new values to them.Connect theConstantblock output signal
c
to the second port of theBus Assignment块。For theBus Assignmentblock, in the Block Parameters dialog boxElements in the buslist, select the
a
signal and clickSelect.Use aBus Selectorto select signals
a
andb
from theconst_bus
bus and connect those signals toDisplayblocks.Simulate the model. TheDisplayblocks show that the value of signal
a
, which was 1 when theconst_bus
bus was created, is now 3, reflecting the assignment of thec
signal from theConst3
块。