How can I convert a color name to a 3 element RGB vector?

后端 未结 4 1636
-上瘾入骨i
-上瘾入骨i 2021-01-12 18:51

In many MATLAB plotting functions, you can specify the color as either a string or as a 3 element vector that directly lists the red, green, and blue values.

For ins

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 19:23

    here's a oneliner you don't have to solve for C:

    str2rgb=@(x)get(line('color',x),'color');
    

    Now str2rgb gives you the answer. for example str2rgb('c') = [0 1 1].

提交回复
热议问题