Possible Duplicate:
MATLAB: convert color name to RGB 3 element vector
MATLAB's ColorSpec concept allows a color to be defined either as a RGB 3-tuple or a fixed color string. I could build a function that uses a lookup table based on the data at the above link to convert between these two color definitions but I worry about changes to this table in future releases.
Is there a built-in function which converts from fixed color to RGB value that does something like the following?
>> fixedColor2RGB('r') ans = [1 0 0]
There is no built-in function to convert between short or long color name strings and their corresponding RGB triplets. However, these fixed color strings have been the standard in MATLAB for as long as I've used it (about 15 years):
So I wouldn't worry too much about changes to this in the future. A simple table lookup should do just fine. And even if they did change things (which seems unlikely), such a simple utility could be easily updated.
精彩评论