Generate evenly distributed coordinates

How can I generate coordinates which are all separated by the same distance? Thanks for your help.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 23일

0 개 추천

distance=2
x=0:distance:100

댓글 수: 1

John
John 2013년 8월 23일
Though this does work in generating equal separation, I'm looking for how I can get N number of coordinates (say 80 coordinates) all over a square (say 20 by 20), and if you were to join the coordinates with their neighbors, you would get an equilateral triangle.

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 24일
편집: Azzi Abdelmalek 2013년 8월 24일

0 개 추천

Edit
n=10
distance=4;
x1=0:distance:(n-1)*distance;
x2=distance/2:distance:n*distance-distance/2;
distancev=distance*sin(pi/3);
y1=0:distancev*2:(n-1)*distancev;
y2=distancev:2*distancev:n*distancev;
a1=repmat(x1,n/2,1);
a2=repmat(y1',1,n);
b1=repmat(x2,n/2,1);
b2=repmat(y2',1,n);
x=[a1(:);b1(:)];
y=[a2(:);b2(:)]
scatter(x,y)

댓글 수: 2

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 24일
Look at EDIT
John
John 2013년 8월 24일
awesome man, exactly what I was looking for, thanks.

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

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2013년 8월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by