I an looking to use an enumeration to access elements of an array or dictionary but having no luck.
Enum:
classdef Enumeration1 < uint32
enumeration
Left (1);
Right (2);
Neither (3);
end
end
Usage:
directions(Enumeration1.Left) = 7;
To me this should be the same as
directions(1) = 7;
but I get 'Subscript indices must either be real positive integers or logicals'.
alternatively when I use a containers.Map
object, all examples I see have keys as strings. When I use an enumeration I get 'Specified key type does not match the type expected for this container'. I can see from help containers.Map
that uint32 is an acceptable key type.
How can I effectively index objects using an enumerated value?