Main Content

matlab.mixin.CustomDisplay Class

Namespace: matlab.mixin

Interface for customizing object display

Description

This class provides an interface for customizing the way MATLAB® displays objects. To add the custom display functionality to your class, derive your class from matlab.mixin.CustomDisplay.

classdef MySubClass < matlab.mixin.CustomDisplay
    ....
end

matlab.mixin.CustomDisplay defines protected methods that you can override in your subclass to customize object display. By overriding specific methods, you can customize specific aspects of the object display. For more information on customizing object display, see Custom Display Interface.

matlab.mixin.CustomDisplay also implements three public, sealed, and hidden methods: disp, display, and details.

disp and display provide a simple object display. The details method provides the formal display of object information.

Note

You cannot use matlab.mixin.CustomDisplay to derive a custom display for enumeration classes. For an alternative approach, see Overloading the disp Function

Class Attributes

Abstract
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Methods

expand all

Examples

collapse all

This class adds a custom footer by overriding the getFooter method.

classdef MyClass < matlab.mixin.CustomDisplay
    properties
        Prop1 = 10
        Prop2
    end
    methods (Access = protected)
        function s = getFooter(~)
            s = 'Here is my custom footer';
        end
    end
end
myObject = MyClass
myObject = 

  MyClass with properties:

    Prop1: 10
    Prop2: []

Here is my custom footer

The default implementation of getFooter returns an empty character vector. MyClass overrides the method to return the text, Here is my custom footer.

Tips

MATLAB displays objects in one of these formats:

  • Deleted scalar handle object

  • Empty object array

  • Scalar object

  • Nonscalar object array

Each format has three sections: a header, a list of properties, and a footer. All formats have default implementation, but classes can customize any of these formats.

Version History

Introduced in R2013b