getHeader

Class: matlab.mixin.CustomDisplay
Package: matlab.mixin

Build and return display header text

Syntax

s = getHeader(obj)

Description

s = getHeader(obj) returns the text used as the header when displaying obj. 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 (if obj is an instance of a handle class).

Input Arguments

obj

Object array of a class derived from matlab.mixin.CustomDisplay

Output Arguments

s

Header string, returned as a char array

The default implementation returns the following:

  • If obj is scalar, returns classname, which is the simple name of the class (the nonpackage-qualified name).

  • If obj is nonscalar, returns classname and dimensions.

  • If obj is empty, returns an empty char.

  • If obj is a deleted handle, returns the string deleted classname handle

classname is linked to MATLAB® documentation for the class. Selecting the link displays the helpPopup window.

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

Examples

expand all

Append the text, 'with Customized Display', to the header text.

Write a getHeader method.

methods (Access = protected)
   function header = getHeader(obj)
      if ~isscalar(obj)
         header = getHeader@matlab.mixin.CustomDisplay(obj);
      else
         headerStr = matlab.mixin.CustomDisplay.getClassNameForHeader(obj);
         headerStr = [headerStr,' with Customized Display'];
         header = sprintf('%s\n',headerStr);
      end
   end
end

Add getHeader method to class definition.

Attributes

Accessprotected

To learn about attributes of methods, see Method Attributes.