This is the inverse to this problem. Given an RGB triplet, return the corresponding ColorSpec string. If the input does not have a known string name, return an empty string. A second optional input indicates whether to return the short (default) or long form.

Examples

rgb2str([1 0 0]) returns 'r'
rgb2str([0 1 0],'short') returns 'g'
rgb2str([0 0 1],'long') returns 'blue'
rgb2str([0.9 0.7 0.1]) returns ''

Solution Stats

169 Solutions

38 Solvers

Last Solution submitted on Dec 04, 2025

Last 200 Solutions

Solution Comments

Show comments
Loading...

Problem Recent Solvers38

Suggested Problems

More from this Author43

Community Treasure Hunt

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

Start Hunting!