MATLAB Object-Oriented Programming

(Joyce) #1

Prop2
Prop3
end
methods(Access = protected)
function groups = getPropertyGroups(obj)
if isscalar(obj)
% Scalar case: change order
propList = {'Prop2','Prop1','Prop3'};
groups = matlab.mixin.util.PropertyGroup(propList)
else
% Nonscalar case: call superclass method
groups = [email protected](obj);
end
end
end
end


Custom Property List with Modified Values


Change the values displayed for some properties in the scalar case by creating property/
value pairs in a struct. This getPropertyGroups method displays only Prop1 and
Prop2, and displays the value of Prop2 as Prop1 divided by Prop3.


classdef MyClass < matlab.mixin.CustomDisplay
properties
Prop1
Prop2
Prop3
end
methods(Access = protected)
function groups = getPropertyGroups(obj)
if isscalar(obj)
% Specify the values to be displayed for properties
propList = struct('Prop1',obj.Prop1,...
'Prop2',obj.Prop1/obj.Prop3);
groups = matlab.mixin.util.PropertyGroup(propList)
else
% Nonscalar case: call superclass method
groups = [email protected](obj);
end
end
end
end


Complete Class Definitions


For complete class implementations, see these sections:



  • “Customize Property Display” on page 18-23


“Customize Header, Property List, and Footer” on page 18-26

Choose a Technique for Display Customization
Free download pdf