|On this page…|
In the process of building the custom display, CustomDisplay methods call the size function at several points:
disp calls size to determine which state handler method to invoke.
The default getHeader method calls size to determine whether to display a scalar or nonscalar header.
The default displayPropertyGroups method calls size to determine if it should look up property values when the property group is a cell array of property names. By default, only scalar objects display the values of properties.
If your class overloads the size function, then MATLAB® calls the overloading version. You must ensure that the implementation of size is consistent with the way you want to display objects of the class.
An unusual or improper implementation of size can result in undesirable display behavior. For example, suppose a class overloads size reports an object as scalar when it is not. In this class, a property list consisting of a cell array of strings results in the property values of the first object of the array being displayed. This behavior can give the impression that all objects in the array have the same property values.
However, reporting an object as scalar when in fact the object is empty results in the object displaying as an empty object array. The default methods of the CustomDisplay interface always determine if the input is an empty array before attempting to access property values.
As you override CustomDisplay methods to implement your custom object display, consider how an overloading size method can affect the result.