MATLAB Object-Oriented Programming

(Joyce) #1
end
end
enumeration
Blueish (18/255,104/255,179/255)
Reddish (237/255,36/255,38/255)
Greenish (155/255,190/255,61/255)
Purplish (123/255,45/255,116/255)
Yellowish (1,199/255,0)
LightBlue (77/255,190/255,238/255)
end
end

You can access the property values via the enumeration member:

Colors.Reddish.R

ans =

0.9294

Suppose that you want to create a plot with the new shade of red named Reddish:

a = Colors.Reddish;
[a.R,a.G,a.B]

ans =

0.9294 0.1412 0.1490

Use these values by accessing the enumeration member properties. For example, the
myPlot function accepts a Colors enumeration member as an input argument. The
function accesses the RGB values defining the color from the property values.

function h = myPlot(x,y,LineColor)
h = line('XData',x,'YData',y);
r = LineColor.R;
g = LineColor.G;
b = LineColor.B;
h.Color = [r g b];
end

Create a plot using a reddish color line:

h = myPlot(1:10,1:10,Colors.Reddish);

14 Enumerations

Free download pdf