This example shows how to create and use a cell array to generate Simulink.Bus
objects in the base workspace.
To define the elements that the Bus
object contains, create an array of Simulink.BusElement
objects or a cell array of the property values for the BusElement
objects.
When you define the elements in an array of BusElement
objects, you must specify the values that differ from the default.
When you define the elements in a cell array of property values, you must specify the element name, dimensions, data type, complexity, and sampling mode. You can also specify the dimensions mode, minimum, maximum, units, and description.
In this example, elementsArray
and elementsCellArray
create the same BusElement
objects in the Bus
objects.
Create a cell array with two subordinate cell arrays that define Bus
objects. For each Bus
object, specify the bus name, header file, description, data scope, alignment, and elements. For the first Bus
object, specify the elements using elementsArray
. For the second Bus
object, specify the elements using elementsCellArray
.
Generate the Bus
objects in the base workspace from the cell array of cell arrays.
Compare the generated Bus
objects in the Bus Editor.
The Bus
objects are identical other than their names.