 <p>MATLAB has a built-in for this. If N is the number of shades you want (471 in your case) you can do</p> <pre><code>N = 471; c = colormap(jet(N)); </code></pre> <p>then access c in every loop iteration via <code>c(i, :)</code>. For reference see the <a href="http://uk.mathworks.com/help/matlab/ref/colormap.html" rel="nofollow">man page</a> ;).</p>