Last active
August 29, 2015 14:21
-
-
Save jnkather/6de1287c446713266e63 to your computer and use it in GitHub Desktop.
Convert hexadecimal color string to RGB values in Matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% (c) Jakob Nikolas Kather 2015 | |
% contact: http://www.kather.me | |
function rgb = hex2rgb(hexString) | |
if size(hexString,2) ~= 6 | |
error('invalid input: not 6 characters'); | |
else | |
r = double(hex2dec(hexString(1:2)))/255; | |
g = double(hex2dec(hexString(3:4)))/255; | |
b = double(hex2dec(hexString(5:6)))/255; | |
rgb = [r, g, b]; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment