📄 hex2rgb.m
字号:
function [rgb,g,b]=hex2rgb(hex,hg,hb)%HEXRGB Convert hex color to 0-1 range color.% RGB=HEXRGB(HEX) where HEX is a three row two-column string matrix or a% string cell or a string of length 6.% Copyright (c) 2001-10-09, B. Rasmus Anthin.% Revisited 2002-03-06if nargin==2,error('Must be 1 or 3 arguments.'),endif nargin==3,hex=[hex hg hb];endif size(hex)==[3 2] & ischar(hex) rgb=[hex2dec(hex(1,:)) hex2dec(hex(2,:)) hex2dec(hex(3,:))]/255elseif size(hex)==[1 6] & ischar(hex) rgb=[hex2dec(hex(1:2)) hex2dec(hex(3:4)) hex2dec(hex(5:6))]/255;elseif iscellstr(hex) rgb=[hex2dec(hex{1}) hex2dec(hex{2}) hex2dec(hex{3})]/255;endif nargout==3 g=rgb(2); b=rgb(3); rgb=rgb(1);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -