In order to customize color order in the plot, I recommond you to use command:
>>?jet(?n?)?%?n?is?the?total?number?of?your?plotsAs you should know, the color is representative by?a three-element row vector, which is the RGB value.
For example:
RGB? color
[000]|black
[110]|yellow
The automatically colorful plot is therefore all about the change of the RGB value by applying [ jet( ) ] command in Matlab.
Here is a simple example code to help you better understand the implication of this command in plot.
n?=?10;%?numberc?=?jet(n);%?color
x?=?0:.01:1;
for?i?=?1:n
y?=?x.^(1+i);
plot(x,y,'color',c(i,:));%?the?key?to?obtian
%?colorful?plot?effect!!!hold?on
end
hold?off
For your question, the code could be written as:
clear?alln?=?100;
[a,b]?=?meshgrid(1:n);
c?=?a?+?b;
cc?=?jet(n*n);
v?=?0;
for?i?=?1:n
for?j?=?1:n
v?=?v?+?1;
plot3(a(i,j),b(i,j),c(i,j),'o','color',cc(v,:))
hold?on
end
end
hold?off
The graphic will be displayed as
However, in my opinion your question doesn't require any excessive command to achieve your request at all.
Here is the modified code to achieve what you expect but yet facter than the previous one.
clear?alln?=?100;
[a,b]?=?meshgrid(1:n);
c?=?a?+?b;
mesh(a,b,c)
Chance is yours!!! Cheers...