MATLAB Object-Oriented Programming
Operations on Enumerations In this section... “Operations Supported by Enumerations” on page 14-19 “Enumeration Class” on page 1 ...
Default Methods Enumeration classes have the following default methods: methods('WeekDays') Methods for class WeekDays: WeekDays ...
ans = char Enumerations and char Vectors in Relational Operations Expression involving the relational operators, eq and ne, in w ...
today = 'Wednesday'; ... if today == WeekDays.Wednesday disp('Team meeting at 2:00') end Enumerations in switch Statements Equal ...
You can use char vectors to represent specific enumeration members: function c = Reminder2(day) switch(day) case 'Monday' c = 'D ...
Mixed Sets of Enumeration and char If you pass both enumeration and char arguments to an enumeration class method, the class att ...
strcmp(today,'Tuesday') ans = 1 How to Get Information About Enumerations Obtain information about enumeration classes using the ...
To determine if the class of a variable class is an enumeration class, use the meta.class object. today = WeekDays.Wednesday; mc ...
Enumeration Class Restrictions Enumeration classes restrict certain aspects of their use and definition: Enumeration classes ar ...
Enumerations Derived from Built-In Types In this section... “Subclassing Built-In Types” on page 14-28 “Derive Enumeration Class ...
Second (50) Third (10) NoPlace (0) end end The enumeration member inherits the methods of the int32 class (except the colon oper ...
ans = 1 How to Create Enumeration Instances When you first refer to an enumeration class that derives from a built-in class such ...
a = No b = Bool.off b = No Superclass Constructor Returns Underlying Value The actual underlying value associated with an enumer ...
Low (10) Medium (50) High (100) end end Reference an instance of an enumeration member: setFlow = FlowRate.Medium; This statemen ...
ans = Yes The converter returns an object of the same size as in input: Bool([0,1]) ans = No Yes Create an empty enumeration arr ...
Mutable Handle vs. Immutable Value Enumeration Members In this section... “Select Handle- or Value-Based Enumerations” on page 1 ...
end end MATLAB considers a and b as equivalent: a = WeekDays.Monday; b = WeekDays.Monday; isequal(a,b) ans = 1 a == b ans = 1 En ...
ans = 1 0 0 You cannot change a property value: red.G = 1; You cannot set the read-only property 'G' of Colors. Handle-Based Enu ...
Red (1, 0, 0) Green (0, 1, 0) Blue (0, 0, 1) end end Create an instance of HandleColors.Red and return the value of the R proper ...
Clear the class to reload the definition of the HandleColors class: clear classes a = HandleColors.Red; a.R ans = 1 To prevent r ...
«
29
30
31
32
33
34
35
36
37
38
»
Free download pdf