In MATLAB, you can extract an enumeration inside a struct using the fieldnames function. Consider the following code:
main.m263 chars15 lines
In the code above, we define an enumeration called MyEnum with three values. We then define a struct called myStruct with a field called myEnumField which is set to MyEnum.Value2.
To extract the enumeration value from the struct, we simply assign it to a variable using dot notation (myStruct.myEnumField), as shown above. The result will be the enumeration value (in this case, MyEnum.Value2).
Note that it's also possible to extract the field names of a struct using the fieldnames function. For example, we could use the following code to get the field names of myStruct:
main.m106 chars6 lines
The result of this code would be:
main.m14 chars2 lines
gistlibby LogSnag