Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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.

Related Examples

Attributes

Accessprotected

To learn about attributes of methods, see Method Attributes in the MATLAB Object-Oriented Programming documentation.

Was this topic helpful?