How to get name of an enumeration in MATLAB
You can use:
» str = char(Color.RED)
str =
RED
» class(str)
ans =
char
You can even override the default behaviour:
classdef(Enumeration) Color < int32
enumeration
RED(0)
GREEN(1)
BLUE(2)
end
methods
function s = char(obj)
s = ['Color ' num2str(obj)];
%# or use a switch statement..
end
function disp(obj)
disp( char(obj) )
end
end
end
and now:
» char(Color.BLUE)
ans =
Color 2