Reputation: 5799
I would like to create a function that contains all text and constant. From the other .m files I access to the constants with giving the name of function variable.
For example, in Java:
public enum MyEnum {
COMBO("val1"),MENU_FILE("File");}
private final String label;
/**
* @param label
*/
private MyEnum(final String label)
{
this.label = label;
}
@Override
public String toString()
{
return this.label;
}
}
Can I do the same with MATLAB?
Can I have a file that contains several enums?
Upvotes: 2
Views: 2050
Reputation: 20915
In the newest versions of Matlab you can:
classdef WeekDays
enumeration
Sunday,Monday %You fill the rest yourself :)
end
end
Then, access it from another file like that:
WeekDays.Sunday;
.m
code, pure Matlab. You need to have Matlab version 2011a or higher. Upvotes: 5