Given a ColorSpec string, either in short or long form, return the corresponding RGB triplet. If the input is not a valid color, return an empty vector.

Examples

str2rgb('red') returns [1 0 0]
str2rgb('k') returns [0 0 0]
str2rgb('pizza') returns []

Solution Stats

137 Solutions

55 Solvers

Last Solution submitted on Dec 08, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers55

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!