image thumbnail


version (1.63 KB) by Peder Axensten
Return the rgb vector of a color name.


Updated 24 Jul 2006

View License

USAGE: color_vector= name2rgb(color_name)

Return the rgb vector of a color name.

name2rgb2({'r', 'blue', 'pp', 'y'})
ans = 1 0 0 0 0 1 NaN NaN NaN 1 1 0

Version 1.0, 2006-07-19.
Version 1.1, 2006-07-22:
- Much more efficient (and elegant?) code, thanks to Urs (us) Schwarz!

Copyright (C) Peder Axensten <>

Cite As

Peder Axensten (2021). name2rgb (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Convert between RGB and Color Names

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!