You can reference Java enum constants from Matlab using the package.class.FIELD syntax, as with any other static Java field. Let's say you have an enum.
package com.example;
public enum MyEnum {
FOO, BAR, BAZ
}
You can get at the enum constants in Matlab using a direct reference. (The Java classes must be in Matlab's javaclasspath, of course.)
% Static reference
foo = com.example.MyEnum.FOO
% Import it if you want to omit the package name
import com.example.MyEnum;
foo = MyEnum.FOO
bar = MyEnum.BAR
If you want a "dynamic" reference determined at runtime, you can just build a string containing the equivalent static reference and pass it to eval(). This works on almost any Matlab code.
% Dynamic reference
foo = eval('com.example.MyEnum.FOO')
And if you want to get really fancy, you can use Java reflection to get at all the enumerated constants at run time. Make a thin wrapper to put with your other custom classes to get around quirks with Matlab's classloader. (There's no Matlab javaClass() equivalent; IMHO this is a Matlab oversight.)
//In Java
package com.example;
public class Reflector {
public static Class forName(String className) throws Exception {
return Class.forName(className);
}
}
Then you can enumerate the constants in Matlab.
% Constant enumeration using reflection
klass = com.example.Reflector.forName('com.example.MyEnum');
enums = klass.getEnumConstants();