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.
Examples
str2rgb('red') returns [1 0 0]
str2rgb('k') returns [0 0 0]
str2rgb('pizza') returns []
Solution Stats
Problem Comments
-
2 Comments
Jean-Marie Sainthillier
on 23 Sep 2015
When I see beautiful and efficient Ly Cao solutions, I have the feeling that Cody has found another master (after Alfonso).
LY Cao
on 23 Sep 2015
Thank you. I'm flattered. I still have a lot to learn.
Solution Comments
Show commentsProblem Recent Solvers52
Suggested Problems
-
6948 Solvers
-
Return the 3n+1 sequence for n
8445 Solvers
-
629 Solvers
-
Determine the number of odd integers in a vector
795 Solvers
-
Relative ratio of "1" in binary number
1542 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!