Why 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?
4 views (last 30 days)
Show older comments
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?
Accepted Answer
MathWorks Support Team
on 25 Jun 2012
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;
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!