MATLAB: Bad property value found

guiguideset

I am using GUIDE (GUI) and I am getting this error:
Error using set
Bad property value found.
Object Name: uicontrol
Property Name: 'BackgroundColor'.
The line that is giving me the error is:
set(handles.text410, 'BackgroundColor', b{4,
10});
b is a cell of colors and b{4, 10} = 'Orange'
I have a bunch of text boxes, and I don't know why it is giving me this error. I have 45 previous set statements with the same format that all work perfectly. Also, I am positive I have the correct tag.
Thanks so much in advance!

Best Answer

'Orange' is not one of the named colors; only one of the eight 'yellow', 'magenta', 'cyan', 'red', 'green', 'blue', 'white', 'black' have common names; you'll have to use the numeric RGB triplet form in your assignment instead or make the array an enumeration class (altho I've not tested the HG property value will accept one for certain, left as "exercise for the student" :) )
ADDENDUM
While one can make enumerations work, I'm not terribly adept but the only way I got working shortly is pretty klunky to use. Maybe somebody else can improve on the following (adapted from a TMW example)
>> type Colors
classdef Colors
properties
R = 0;
G = 0;
B = 0;
RGB=[0 0 0];
end
methods
function c = Colors(r, g, b)
c.R = r; c.G = g; c.B = b;
c.RGB= [c.R c.G c.B];
end
end
enumeration
Orange (222/255,125/255,0)
end
end
>>
Can manage to use this as
>> plot(x,y,'color',Colors.Orange.RGB)
>>
But this seems to me to require too much intimate knowledge of the class to be desirable. Need some way to be able to return the desired RGB vector from just the name but I couldn't figure out a syntax to do that in the short time I've played with it. (If you can't tell, I'm not an OO kinda' guy... :) )