Documentation Center

  • Trial Software
  • Product Updates

getPropertyGroups

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

Construct array of property groups

Syntax

groups = getPropertyGroups(obj)

Description

groups = getPropertyGroups(obj) returns an array of matlab.mixin.util.PropertyGroup objects. MATLAB® displays property groups separated by blank spaces.

Each default display state handler method calls this method once. The default implementation returns the properties in one group. These properties must have public GetAccess and not be defined as Hidden. If the object is scalar, MATLAB includes dynamic properties.

Override this method to construct one or more customized groups of properties to display.

Each group object array has the following fields:

  • Title — String used as the header for the property group or an empty string if no title is used.

  • PropertyList — The property list can be either:

    • A 1-by-1 struct of property name-property value pairs

    • A cell array of string property names.

Use the struct of name-value pairs if the object is scalar and you want to assign custom property values. Otherwise, use a cell array of string property names. If the object is scalar MATLAB adds the property values retrieved from the object.

Input Arguments

obj

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

Output Arguments

groups

1xN array of matlab.mixin.util.PropertyGroup objects, where N is the number of groups

Examples

expand all

Custom Property Group

Customize the values returned by some properties.

Write a getPropertyGroups method.

methods (Access = protected)
   function propgrp = getPropertyGroups(obj)
      if ~isscalar(obj)
         propgrp = getPropertyGroups@matlab.mixin.CustomDisplay(obj);
      else
         pd(1:length(obj.Password)) = '*';
         propList = struct('Department',obj.Department,...
            'JobTitle',obj.JobTitle,...
            'Name',obj.Name,...
            'Salary','Not avalable',...
            'Password',pd);
         propgrp = matlab.mixin.util.PropertyGroup(propList);
      end
   end
end

Add function to class definition.

Attributes

Accessprotected

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

See Also

| |

Was this topic helpful?