5.0

5.0 | 4 ratings Rate this file 63 downloads (last 30 days) File Size: 4.46 KB File ID: #24497

RGB triple of color name, version 2

by Kristjan Jonasson

 

20 Jun 2009 (Updated 05 Jul 2009)

Code covered by BSD License  

Returns a Matlab RGB color specifier corresponding to a given color name (139 colors supported).

Download Now | Watch this File

File Information
Description

RGB = RGB('COLORNAME') returns the red-green-blue triple corresponding to the color named COLORNAME by the CSS3 proposed standard [1], 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).

EXAMPLES
  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'

REFERENCES
[1] "CSS Color module level 3", W3C (World Wide Web Consortium) working draft 21 July 2008, http://www.w3.org/TR/css3-color.
[2] "Web colors", http://en.wikipedia.org/wiki/Web_colors

MATLAB release MATLAB 7.7 (R2008b)
Zip File Content  
Other Files license.txt,
rgb.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
22 Jun 2009 us

excellent in-depth help including many references...
easily expandable look-up table engine...
certainly very useful for color-freaks...
us

08 Jul 2009 Husam Aldahiyat

Amaaazing!

19 Aug 2009 Sabine  
27 Aug 2009 K R

this is so simple and brilliant!!! What a massive time-saver and figure-improver!! A million thanks!!

Please login to add a comment or rating.
Updates
05 Jul 2009

VERSION 2 allows finding color name given rgb triple.

Tag Activity for this File
Tag Applied By Date/Time
color Kristjan Jonasson 22 Jun 2009 11:14:36
rgb Kristjan Jonasson 22 Jun 2009 11:14:37
colour Kristjan Jonasson 22 Jun 2009 11:14:37
color name Kristjan Jonasson 22 Jun 2009 11:14:37
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com