From: natalie lowery on
I've got...
for k=1:K
for m=(((k-1)*M)+1):(k*M)
plot (X(m,2), X(m,3), '*')
end
end

I have N points that I'm plotting and M=N/K.

I want to plot each group of points in the same colour. So for example if K=3 I might want the first N/3 of the points to be red and then the second N/3 to be blue, etc... Of course when K=3 I can do this quite easily by splitting up the cases but for large K I need a general method.

Any ideas? Nat xx
From: fabio freschi on
"natalie lowery" <n.l.h.lowery(a)student.reading.ac.uk> wrote in message <i26ot4$aj1$1(a)fred.mathworks.com>...
> I've got...
> for k=1:K
> for m=(((k-1)*M)+1):(k*M)
> plot (X(m,2), X(m,3), '*')
> end
> end
>
> I have N points that I'm plotting and M=N/K.
>
> I want to plot each group of points in the same colour. So for example if K=3 I might want the first N/3 of the points to be red and then the second N/3 to be blue, etc... Of course when K=3 I can do this quite easily by splitting up the cases but for large K I need a general method.
>
> Any ideas? Nat xx

Try this

K = 3; % number of points in each group;
M = 10; % number of groups;

N = M*K; % total number of points

col = repmat(1:M,K,1); % define colors by index value
col = col(:); % now col is Nx1

x = rand(N,1);
y = rand(N,1);

scatter(x,y,30,col(:),'filled')

Fabio
From: Maxx Chatsko on
"natalie lowery" <n.l.h.lowery(a)student.reading.ac.uk> wrote in message <i26ot4$aj1$1(a)fred.mathworks.com>...
> I've got...
> for k=1:K
> for m=(((k-1)*M)+1):(k*M)
> plot (X(m,2), X(m,3), '*')
> end
> end


Split it up and use scatter()
Example from older post:
colors = [ [1;1;1] [1;1;.3] [1;.2;.4] [.5;.6;.2] ];
plot(x1(1,:), x1(2,:), 'o', 'Color', colors)
Maxx


From: us on
"natalie lowery" <n.l.h.lowery(a)student.reading.ac.uk> wrote in message <i26ot4$aj1$1(a)fred.mathworks.com>...
> I've got...
> for k=1:K
> for m=(((k-1)*M)+1):(k*M)
> plot (X(m,2), X(m,3), '*')
> end
> end
>
> I have N points that I'm plotting and M=N/K.
>
> I want to plot each group of points in the same colour. So for example if K=3 I might want the first N/3 of the points to be red and then the second N/3 to be blue, etc... Of course when K=3 I can do this quite easily by splitting up the cases but for large K I need a general method.
>
> Any ideas? Nat xx

a hint:

help scatter; % <- and siblings...

us
From: natalie lowery on
Thanks I'll have a play around with those ideas.- Nat x