MATLAB: Do I get an error in MATLAB Coder 2.2 (R2012a) when instantiating an Enumerated data type with an Enumerated data type as its argument

coderconstructorenumeratedinstantiateint32MATLABmatlab coder

I have defined an Enumerated class which inherits the int32 class as described in the Code Generation documentation.
classdef(Enumeration) MyEnum < int32
enumeration
OK(1),
Error(2),
Warning(3),
end
end
The MATLAB file I am generating code from has the following two statements:
x = MyEnum(2);
x = MyEnum(MyEnum.Error);
Code generation is successful with the first line, but not with the second. I am receiving the following error:
??? Expression must be numeric. Found it to be MyEnum.
Both lines, however, have the same effect when running them in MATLAB. Why can't code be generated from the second line?

Best Answer

The ability to instantiate an Enumerated data type with another Enumerated data type as an argument is currently unsupported in MATLAB Coder 2.2 (R2012a).
As a workaround, please use either of the following statements:
x = MyEnum(2);
x = MyEnum.Error;