Assign into Elements of Array of Buses
This example shows how to assign data for the buses in an array of buses. MATLAB Function blocks can directly assign the data for a bus in an array of buses. They can also make a partial assignment to certain elements in the array of buses.
Open the example model, which contains a MATLAB Function block that receives a nonvirtual bus.
The In Bus Element and Out Bus Element blocks specify a Simulink.Bus
object named A
. To view the hierarchy and specified attributes of the input bus, double-click the In Bus Element block named InBus
.
The top-level bus is a nonvirtual bus defined by the Simulink.Bus
object named A
. The bus element named a1
is an array of buses. It contains ten nonvirtual buses defined by the Bus
object named B
.
The MATLAB Function block specifies Bus
object A
as the data type for the block input and output. To view this specification, double-click the MATLAB Function block. In the toolstrip, on the Function tab, click Ports & Data Manager.
The MATLAB Function block uses a function to iteratively assign new values to element b
of each nonvirtual bus in the array of buses. The function also assigns a new value to bus element a
.