http://www.mathworks.com/matlabcentral/newsreader/view_thread/320132
MATLAB Central Newsreader  Generateing a number of points in 2D
Feed for thread: Generateing a number of points in 2D
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Wed, 16 May 2012 12:46:09 +0000
Generateing a number of points in 2D
http://www.mathworks.com/matlabcentral/newsreader/view_thread/320132#876994
HU Jianho
Hi there,<br>
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:<br>
[0 0]<br>
[1 0]<br>
[0 1]<br>
[1 0]<br>
[0 1]<br>
[1 1]<br>
[1 1]<br>
[1 1]<br>
[1 1]<br>
[2 0]<br>
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).<br>
<br>
Any help will be appreciated.

Wed, 16 May 2012 20:11:14 +0000
Re: Generateing a number of points in 2D
http://www.mathworks.com/matlabcentral/newsreader/view_thread/320132#877039
Roger Stafford
"HU Jianho" wrote in message <jp07ig$hcv$1@newscl01ah.mathworks.com>...<br>
> Hi there,<br>
> 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:<br>
> [0 0]<br>
> [1 0]<br>
> [0 1]<br>
> [1 0]<br>
> [0 1]<br>
> [1 1]<br>
> [1 1]<br>
> [1 1]<br>
> [1 1]<br>
> [2 0]<br>
> 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).<br>
> <br>
> Any help will be appreciated.<br>
          <br>
Let N be the desired number of points.<br>
<br>
n = ceil(sqrt(N/3));<br>
[X,Y] = ndgrid(n:n);<br>
[~,q] = sortrows([X(:).^2+Y(:).^2,mod(atan2(Y(:),X(:)),2*pi)],[1 2]);<br>
P = [X(q(1:N)),Y(q(1:N))];<br>
<br>
Roger Stafford

Thu, 17 May 2012 10:12:07 +0000
Re: Generateing a number of points in 2D
http://www.mathworks.com/matlabcentral/newsreader/view_thread/320132#877101
HU Jianho
"Roger Stafford" wrote in message <jp11l2$je7$1@newscl01ah.mathworks.com>...<br>
> "HU Jianho" wrote in message <jp07ig$hcv$1@newscl01ah.mathworks.com>...<br>
> > Hi there,<br>
> > 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:<br>
> > [0 0]<br>
> > [1 0]<br>
> > [0 1]<br>
> > [1 0]<br>
> > [0 1]<br>
> > [1 1]<br>
> > [1 1]<br>
> > [1 1]<br>
> > [1 1]<br>
> > [2 0]<br>
> > 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).<br>
> > <br>
> > Any help will be appreciated.<br>
>           <br>
> Let N be the desired number of points.<br>
> <br>
> n = ceil(sqrt(N/3));<br>
> [X,Y] = ndgrid(n:n);<br>
> [~,q] = sortrows([X(:).^2+Y(:).^2,mod(atan2(Y(:),X(:)),2*pi)],[1 2]);<br>
> P = [X(q(1:N)),Y(q(1:N))];<br>
> <br>
> Roger Stafford<br>
<br>
Many thanks Roger, that exactly what I want.