matlab.mixin.CustomDisplay.getHeader - Build customized display header text - MATLAB (original) (raw)

Main Content

Class: matlab.mixin.CustomDisplay
Namespace: matlab.mixin

Build customized display header text

Description

[s](#mw%5F10b6c72d-277c-4675-97d0-54117508ca5d) = getHeader([obj](#mw%5F4fac6261-9af8-46eb-b03c-a8ac893122a8)) returns the text s used as the header when displaying the object arrayobj. This method is called once for the entire object array.

Override this method to create a custom header. The overriding implementation must support all states of the object, including scalar, nonscalar, empty, and deleted (ifobj is an instance of a handle class).

Input Arguments

expand all

Object array to apply custom header to. The class of obj must be derived from matlab.mixin.CustomDisplay.

Output Arguments

expand all

Custom header text, returned as a char array. Depending on the inputobj, the default implementation returns:

The class name is linked to MATLAB® documentation for the class. Selecting the link displays thehelpPopup window.

If you override this method, you might need to terminate s with a newline (\n) character.

Examples

expand all

The Tester class has one property,ObjectUnderTest, which can take any type of value. Add agetHeader method that, for scalar instances, identifies the class of the property value and then appends the name of that class to the header.

classdef Tester < matlab.mixin.CustomDisplay properties ObjectUnderTest end methods(Access = protected) function out = getHeader(obj) if ~isscalar(obj) out = getHeader@matlab.mixin.CustomDisplay(obj); else testerClass = matlab.mixin.CustomDisplay.getClassNameForHeader(obj); objectUnderTestClass = class(obj.ObjectUnderTest); headerStr = [testerClass ' for ' objectUnderTestClass]; out = sprintf('%s\n',headerStr); end end end end

Create a scalar instance to see the customized header text.

b = Tester; b.ObjectUnderTest = int8(5)

b =

Tester for int8

ObjectUnderTest: 5

Version History

Introduced in R2013b