External Interfaces |
Enumerated Types
For arguments defined as C enumerated types, you can pass either the enumeration string or its integer equivalent.
The readEnum
function from the shrlibsample
library returns the enumeration string that matches the argument passed in. Here is the Enum1
definition and the readEnum
function in C:
enum Enum1 {en1 = 1, en2, en4 = 4} TEnum1; char* readEnum(TEnum1 val) { switch (val) { case 1 :return "You chose en1"; case 2: return "You chose en2"; case 4: return "You chose en4"; default : return "enum not defined"; } }
In MATLAB, you can express an enumerated type as either the enumeration string or its equivalent numeric value. The TEnum1
definition above declares enumeration en4
to be equal to 4
. Call readEnum
first with a string:
Now call it with the equivalent numeric argument, 4
:
Primitive Types | Structures |
© 1994-2005 The MathWorks, Inc.