Main Content

Customize Object Display for Classes

Customize how MATLAB® displays objects of your class in the command window

The CustomDisplay class defines an interface that you can use to customize how MATLAB displays objects. For an overview of the interface, see Custom Display Interface. In addition, the CustomCompactDisplayProvider class enables you to customize the display of objects in containers, such as structs and tables. For an overview of the interface, see Custom Compact Display Interface.


displayShow information about variable or result of expression
detailsDisplay array details


matlab.mixin.CustomDisplayInterface for customizing object display
matlab.mixin.util.PropertyGroupCustom property list for object display
matlab.mixin.CustomCompactDisplayProviderInterface for customizing object display within containers
matlab.display.CompactDisplayRepresentationBase class for representing compact display of object array
matlab.display.DisplayConfigurationDescribe display environment and settings
matlab.display.DimensionsAndClassNameRepresentationCompact display representation using dimensions and class name
matlab.display.PlainTextRepresentationCompact display representation using data in object array


Custom Display Interface Class and Methods

Custom Display Interface

The CustomDisplay class provides an API for customizing the display of objects of your class.

How CustomDisplay Works

MATLAB determines the state of an object and then calls specific methods for that state to display the object.

Class with Default Object Display

This example class customizes various aspects of object display.

Role of size Function in Custom Displays

MATLAB uses the size function to help determine the state of the object to display.

Specific Techniques for Customizing Object Display

Choose a Technique for Display Customization

You can customize object display based on the state of the object and you can change different parts of the display.

Customize Property Display

Change the order and number of properties displayed for an object of your class.

Customize Header, Property List, and Footer

Customize each of the three parts of the display — header, property groups, and footer.

Customize Display of Scalar Objects

Customize the display of scalar objects.

Customize Display of Object Arrays

Customize the display of nonscalar objects, including empty object arrays.

Customize Display for Heterogeneous Arrays

You can call only sealed methods on nonscalar heterogeneous arrays.

Overloading the disp Function

Overloading the disp function provides limited display customization.

Customizing Compact Displays

Custom Compact Display Interface

Customize the representation of objects in compact display scenarios.