MATLAB: Coloring of different index/numbered points

MATLAB

Hi all,
I have several points say 100 points. Each points have unique index/number from 1 to 100. I want to see 1 to 20 index point as blue color, 21-40 index point is red, 41-60 is green,61-80 is yellow ,and 81-100 is purple. How can I do this? Thanks in advance.

Best Answer

try this:
markerSize = 50;
x = rand(100, 1);
y = rand(100, 1);
plot(x(1:20), y(1:20), 'b.', 'MarkerSize', markerSize);
hold on;
plot(x(21:40), y(21:40), 'r.', 'MarkerSize', markerSize);
plot(x(41:60), y(41:60), 'g.', 'MarkerSize', markerSize);
plot(x(61:80), y(61:80), 'y.', 'MarkerSize', markerSize);
purple = [0.6, 0, 0.6];
plot(x(81:100), y(81:100), '.', 'Color', purple, 'MarkerSize', markerSize);
grid on;