Construct object arrays, reference objects and their properties from arrays, and design class hierarchies that support the formation of heterogeneous (mixed class) arrays.
empty | Create empty array of specified class |
matlab.mixin.Heterogeneous | Superclass for heterogeneous array formation |
Build object arrays in the constructor and return the array as the output argument.
MATLAB® calls the class constructor with no arguments to initialize array elements with a default object.
Initialize Arrays of Handle Objects
MATLAB uses a default object to initialize the empty elements of an array of handle objects.
Empty arrays have no elements, but are of a certain class.
Accessing Dynamic Properties in Arrays
Access dynamic properties in object arrays by referring to individual objects.
You can concatenate objects into arrays.
Concatenating Objects of Different Classes
MATLAB follows specific rules when you attempt to create an array with objects of different classes.
MATLAB attempts to convert elements to the class of the array as a result of concatenation or assignment.
You can convert an object of one class to an object of another class.
You can determine the class of an array.
Designing Heterogeneous Class Hierarchies
Heterogeneous arrays can contain objects of different class, but all objects in the array must derive from a common superclass.
Heterogeneous Array Constructors
The class of a heterogeneous object array can change as you add array elements of different classes. You must ensure that constructors return objects that are the same class as the class defining the constructor.