Given the following two classes
classdef EnumClass enumeration enumVal1 enumVal2 end end classdef EnumDisplay properties enumValue = EnumClass.enumVal1 numberValue = 1 end end
When EnumClass displayed, the value is displayed:
>> E = EnumClass.enumVal1 E = enumVal1
but when EnumDisplay is displayed in the command window, the enumeration value is suppressed, and only the size and class of the array are displayed.
>> C = EnumDisplay() C = EnumDisplay with properties: enumValue: [1x1 EnumClass] numberValue: 1
What is the easiest way to display an enumeration value in a class property list. That is, there is a simple and general way to display a class as follows:
>> C = EnumDisplay() C = EnumDisplay with properties: enumValue: enumVal1 numberValue: 1
I suspect this has something to do with inheriting from the matlab.mixin.CustomDisplay class, but I want it to be as general as possible to limit the amount of coding I need to do for each enum class, and / or each a class that has an enumeration value in a property.
Partial solution
I managed to figure out a partial solution to this problem, but it is not entirely satisfactory.
classdef EnumDisplay < matlab.mixin.CustomDisplay properties enumValue = EnumClass.enumVal1 numberValue = 1 end methods (Access = protected) function groups = getPropertyGroups(This) groups = getPropertyGroups@matlab.mixin.CustomDisplay (This); groups.PropertyList.enumValue = char(This.enumValue); end end end
Now the display looks like this:
>> C = EnumDisplay() C = EnumDisplay with properties: enumValue: 'enumVal1' numberValue: 1
It is almost there, but not quite. I do not want the listed value to be in quotes.
oop enumeration matlab
hoogamaphone
source share