开发者

How to convert MATLAB fixed color to RGB value? [duplicate]

This question already has answers here: 开发者_JS百科 Closed 11 years ago.

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):

How to convert MATLAB fixed color to RGB value? [duplicate]

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜