フィルターのクリア

Generate evenly distributed coordinates

2 ビュー (過去 30 日間)
John
John 2013 年 8 月 23 日
How can I generate coordinates which are all separated by the same distance? Thanks for your help.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 23 日
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 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by