MATLAB Object-Oriented Programming

(Joyce) #1

  1. Employee:
    Name: 'Nancy Green'
    Department: 'Documentation'


Deleted object handles in the array indicate their state:

1x3 EmployeeInfo members:


  1. Employee:
    Name: 'Bill Tork'
    Department: 'Product Development'

  2. handle to deleted EmployeeInfo

  3. Employee:
    Name: 'Nancy Green'
    Department: 'Documentation'


To achieve the desired result, the EmployeeInfo class overrides the following methods
of the matlab.mixin.CustomDisplay class:


  • displayNonScalarObject — Called to display nonempty object arrays

  • displayEmptyObject — Called to display empty object arrays


The displayNonScalarObject Override


MATLAB calls the displayNonScalarObject method to display object arrays. The
override of this method in the EmployeeInfo class:


  • Builds header text using convertDimensionsToString to obtain the array size and
    getClassNameForHeader to get the class name with a link to the help for that class.

  • Displays the modified header text.

  • Loops through the elements in the array, building two different subheaders depending
    on the individual object state. In the loop, this method:

    • Detects handles to deleted objects (using the isvalid handle class method). Uses
      getDeletedHandleText and getClassNameForHeader to build text for array
      elements that are handles to deleted objects.

    • Builds a custom subheader for valid object elements in the array



  • Creates a PropertyGroup object containing the Name and Department properties
    for valid objects


18 Customizing Object Display

Free download pdf