Convert hex color specification to MATLAB RGB - MATLAB Cody - MATLAB Central

Problem 540. Convert hex color specification to MATLAB RGB

Difficulty:Rate

Here's something that comes up all the time if you deal with web pages.

Given a hexadecimal color specification of the form #FFFFFF, convert it to a 3 element MATLAB color specification. Remember that MATLAB RGB color values are between 0 and 1.

The input is a string starting with '#'. The output should be a 1-by-3 vector.

Examples:

 Input  '#0000FF'
 Output [0 0 1]
 Input  '#33FF00'
 Output [0.2 1 0]

Solution Stats

50.46% Correct | 49.54% Incorrect
Last Solution submitted on Jun 25, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers247

Suggested Problems

More from this Author50

Problem Tags

Community Treasure Hunt

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

Start Hunting!