Problem 42612. Convert ColorSpec string to RGB triplet

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.


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

Solution Stats

42.64% Correct | 57.36% Incorrect
Last Solution submitted on Jul 12, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers49

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!