-2

I have a matrix A of size (N, 80), Where values of Aare updated every Nth iteration.

How can I use a color vector of 80 corresponding to the matrix A? I do not want to use a for loop, as it consumes lot of time in every iteration.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Uday
  • 45
  • 6
  • 1
    What do you mean by "a color vector of 80 corresponding to the matrix A"? – nicoguaro Jan 27 '16 at 19:59
  • 2
    Some code would be nice. – beaker Jan 27 '16 at 20:07
  • 1
    `for` loops are actually not so slow any longer, since the engine was overhauld for R2015a – Adriaan Jan 27 '16 at 20:07
  • 1
    Look at the very bottom of the documentation page for plot http://www.mathworks.com/help/matlab/ref/plot.html in the More About section. It says - "You can change the default colors and line styles by setting default values for the ColorOrder and LineStyleOrder properties" but its not very clear to me how. If not, get the handle to your line objects when you plot and then loop through the objects to assign a color to each. As said above `for` loops are not so slow any longer. – Some Guy Jan 27 '16 at 20:13
  • 2
    It doesn't even matter if they're slow. Write functioning code **first**, then worry about optimization. – sco1 Jan 27 '16 at 20:14

1 Answers1

1

You can create a color matrix color consisting of RGB triplets for the 80 different colors you have (this would be an 80 x 3 matrix). Set it as the Default Axes Color Order by using:

>> set(groot,'defaultAxesColorOrder',colors)
>> plot(A) % Will plot the 80 columns with colors corresponding to color

To reset your default Axes colors to factory

>> set(groot,'defaultAxesColorOrder','factory')
Some Guy
  • 1,787
  • 11
  • 15