Hello all,
I trying to understand enumerations and how they are to be used in matlab. I have 2 questions:
1.: In C# I can just define enums in a class:
enum someSpecificValues { one = 1, two = 2, three = 3 }:
And later use them
var enumTest = someSpeficValues.one;
Now, what I understood from the MATLAB help is that I need to define each enum as a class and then call that from within my class. I am developing a driver library, where I need a couple of settings as enums. Do I really need to define them in that way or is there a way to define them within the class? Creating them inside the class has the added advantage that they're confined to the class, where they make sense.
2.: Along with my driver I'd like to create some examples in the app creator, where I want to display these enumerated values as drop down menus, so people don't just enter random values. Is there a way to link the drop down to the enumeration or would I have to write the values by hand and hope not to make an error? Again, in C# you could bind the drop down to the enum (technically, you'd bind to the list, but the effect is the same) and changes to the enum would be reflected on your UI.
I have tried to use the DropDown.Items property and realized this accepts string arrays and not enumerations. I don't know how to correctly convert my enumeration, though. Suppose I have the class:
classdef readModes
enumeration
ZIF, SH, SHN, HDR, DD
end
end
Then the following would not work.
app.DropDown.Items = enumeration(readModes.ZIF);
But what does?