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 instance, these two statements are equivalent:
plot(x, y, 'Color', 'r');
plot(x, y, 'Color', [1 0 0]);
There are 8 colors that can be specified by a string value: 'r','g','b','c','m','y','k','w'
. Is there a MATLAB built-in function that converts these strings to an equivalent RGB vector?
Since R2020b you can use validatecolor
for this.