MATLAB: How to do plotting with different colors in same figure

colorMATLABplotting

My sample code is this:
x=[1:100];
for i=1:5
y(:,i)=i*log(x);
end
This plots 5 different curves of same color.
How to plot each curve with a different color ?

Best Answer

Hi!
If you plot like
plot(x,y)
and y is a matrix, you get plots with different color automatically. But you can do something like this to get manual coloring:
colorstring = 'kbgry';
figure(1); cla;
hold on
for i = 1:5
plot(x,y(:, i), 'Color', colorstring(i))
end