|
"natalie lowery" <n.l.h.lowery@student.reading.ac.uk> wrote in message <i26ot4$aj1$1@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
|