"Roger Stafford" wrote in message <jp11l2$je7$1@newscl01ah.mathworks.com>...
> "HU Jianho" wrote in message <jp07ig$hcv$1@newscl01ah.mathworks.com>...
> > Hi there,
> > I would like to generate a cluster of points around the zero in two dimention. For example if I want to generate 10 points locating the first point at the zero then the points will be as following:
> > [0 0]
> > [1 0]
> > [0 1]
> > [1 0]
> > [0 1]
> > [1 1]
> > [1 1]
> > [1 1]
> > [1 1]
> > [2 0]
> > I want a function do that even the number of points is changed and also I want the distributing process be in same direction (clockwise or anticlockwise).
> >
> > Any help will be appreciated.
>          
> Let N be the desired number of points.
>
> n = ceil(sqrt(N/3));
> [X,Y] = ndgrid(n:n);
> [~,q] = sortrows([X(:).^2+Y(:).^2,mod(atan2(Y(:),X(:)),2*pi)],[1 2]);
> P = [X(q(1:N)),Y(q(1:N))];
>
> Roger Stafford
Many thanks Roger, that exactly what I want.
