uniformly distributed coordinate points

can anyone help me to generate uniformly distributed coordinate points inside a rectangular field.
Thanking u advance

답변 (5개)

Sarah Wait Zaranek
Sarah Wait Zaranek 2011년 3월 10일

2 개 추천

You can also do the following if you want a uniform grid:
[X,Y] = meshgrid(linspace(1,1000,100),linspace(1,1000,100));
This will give X coordinates and Y coordinates for each grid point inside a 1000 x 1000 rectangle. The segmenting in terms of x and y are defined by the input vectors, in this case, I am choosing 100 points per side.
scatter(X(:),Y(:))
will show you all the points.
Andreas Goser
Andreas Goser 2011년 3월 10일

0 개 추천

This sounds like a one-liner with RAND or RANDI for me. Do you run into issues with this command or did you just not find it?

댓글 수: 1

Basanta
Basanta 2011년 3월 10일
no, actually I need to generate coordinates from a 1000x1000 meter rectangular field. the coordinates should be uniformly distributed...
plz help...

댓글을 달려면 로그인하십시오.

Matt Tearle
Matt Tearle 2011년 3월 10일

0 개 추천

xmin = -3;
xmax = pi;
npts = 42;
x = xmin + (xmax-xmin)*rand(npts,1);
Repeat for y.

댓글 수: 4

Basanta
Basanta 2011년 3월 10일
after repeating, should I get a uniformly distributed coordinates?
Matt Tearle
Matt Tearle 2011년 3월 10일
yes. what i showed generates 42 x-coordinates uniformly distributed between -3 and pi. do the same for y, then scatter(x,y) will show the result.
Oleg Komarov
Oleg Komarov 2011년 3월 10일
To get all at once:
min = [ 1 1];
max = [10 3];
npts = 1000;
xy = bsxfun(@plus, min, bsxfun(@times, max-min,rand(npts,2)));
f = scatter(xy(:,1),xy(:,2),'.');
xlim([0,11])
ylim([0,4])
Matt Tearle
Matt Tearle 2011년 3월 10일
ahahaha. nice :)

댓글을 달려면 로그인하십시오.

sh
sh 2013년 6월 17일

0 개 추천

Hi, thanks for your help. can you find the x-coordinate and y-coordinates of these points by coding only? many thanks
Edward Goodison
Edward Goodison 2020년 8월 11일
편집: Edward Goodison 2020년 8월 11일

0 개 추천

[X,Y,Z] = meshgrid(linspace(Start,stop, number of points),linspace(Start,stop, number of points), linspace(Start,stop, number of points));
p = [X(:), Y(:), Z(:)]

댓글 수: 2

Rik
Rik 2020년 8월 11일
Why not use [X(:), Y(:), Z(:)] instead of the loop?
Edward Goodison
Edward Goodison 2020년 8월 11일
nice, good improvement, will edit.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2011년 3월 10일

편집:

2020년 8월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by