RGB = RGB('COLORNAME') returns the red-green-blue triple corresponding to the color named COLORNAME by the CSS3 proposed standard , which contains 139 different colors (an rgb triple is a 1x3 vector of numbers between 0 and 1). The color names are the ones accepted by almost all web browsers, for example Brown, DarkRed, SlateGray.
RGB CHART creates a figure window showing all the available colors with their names.
COLORNAME = RGB(r,g,b) and COLORNAME = RGB([r,g,b]) both find the name of the color with the triple that is closest to [r,b,g] (measured by sum of squares).
c = rgb('DarkRed') gives c = [0.5430 0 0]
c = rgb('Green') gives c = [0 0.5 0]
plot(x,y,'color',rgb('orange')) plots an orange line through x and y
rgb chart shows all the colors
cnam = rgb(0.8,0.3,0.3) gives cnam = 'IndianRed'
Very well! Thanks.
I am having troubles running the rgb.m, when I try to run it Matlab gives me the following error:
function rgb = rgb(s)
Error: Function definitions are not permitted in this context.
Someone has any ideas? Thanks
Very helpful! My advice : print the sheet with all colors and save the rgb function in a folder then add this folder with 'set path'. Then it would be very easy to use any color ;)
straightforward and very helpful! Thanks a lot!
Very easy to use and works perfectly! Thanks a lot
Really good perfect program!
@Artemiy Vyacheslavov: you don't need to "combine" anything. The function that I wrote (at the link you gave) converts in both directions: from RGB to colorname, and also from colorname to RGB.
So why "combine" when my submission does both conversions already? It does not require any supporting functions.
Combined with the reverse conversion script (http://www.mathworks.com/matlabcentral/fileexchange/48155-convert-between-rgb-and-colornames) works perfectly!
Thanks so much. It's great to be able to use more than the basic colors.
and it would be even better, if you will consider to add recently updated default colororder used in plots for the list of color shortcuts! thanks
As some commenters have noted, this submission does not match RGB -> colornames. I wrote a color identifier function to convert between RGB and colornames (both ways):
The user can also choose the to match RGB values using least-squares, or one of the color-difference methods CMC2:1, CIE76, or CIE94 (the default). A bonus function is also included that demonstrates that differences between these matching methods. For more info see also: https://en.wikipedia.org/wiki/Color_difference
By coincidence, this function works with the rgbmap function described here: http://www.mathworks.com/matlabcentral/fileexchange/46874-rgbmap-color-maps/content/rgbmapdemo/html/rgbmap_demo.html
Very useful :-)
Very useful. Thanks!
Great!! very useful.
Great function! Very helpful.
As others have mentioned the colorname = rgb(r, g, b) has not been implemented though!
Highly useful function! However, your Version 2 seems to have not been uploaded. The current function will not accept 3 inputs [R,G,B] to return a color name, as you describe. Please update!
At last an easy way to select Matlab colors. Before your script it was frustrating.
Very useful. Given the frustratingly few default choices in Matlab, this can extend your lifespan by a few day!
cool~, I was looking for this, thank you.
This is a great tool however I am having a few issues. When I use your example code:
cnam = rgb(0.8,0.3,0.3)
??? Error using ==> rgb
Too many input arguments.
This is great! Thanks so much!
very handy, thanks!
this is so simple and brilliant!!! What a massive time-saver and figure-improver!! A million thanks!!
excellent in-depth help including many references...
easily expandable look-up table engine...
certainly very useful for color-freaks...
VERSION 2 allows finding color name given rgb triple.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.