I have defined an enumeration type for "Boolean", subclassed from 'int32' as shown in the Code Generation documentation examples.
classdef Boolean < int32 enumeration False(0) True(1) endend
The MATLAB code I have written to utilize this class has the following IF statement:
x = Boolean.True;if x ...end
When I try to build the Coder project, I get the following error:
??? Expected either a logical, char, int, single, double or fi that can represent zero. Found a Boolean.
This works fine with the following statements:
if int32(x) ...endif x == 1 ...endif x == Boolean.True ...end
If the Boolean class inherits the int32 class, why does my original code not generate correctly with MATLAB Coder 2.2 (R2012a)?
Best Answer