フィルターのクリア

how to generate random point that have fix distance between each point

3 ビュー (過去 30 日間)
Jordan
Jordan 2021 年 6 月 27 日
回答済み: Matt J 2021 年 6 月 27 日
i can generate random point within a specific area
like this
x=rand(1,100)*5
y=rand(1,100)*5
scatter(x,y)
but i want each point generated within x<1 & y<1
must not be less than 0.05 near the pervous generated points. so no interaction between each point generated.
is it any fucntion can do thing like that?

採用された回答

Matt J
Matt J 2021 年 6 月 27 日
Another idea is to generate a chequerboard, and then pick a random point inside all the black (or all the white) squares.
[x,y]=ndgrid((0:2:19)/20);
x=x(:)+rand(size(x(:)))*0.05;
y=y(:)+rand(size(y(:)))*0.05;
scatter(x,y)

その他の回答 (1 件)

dpb
dpb 2021 年 6 月 27 日
I see two possible simple alternatives--
  1. Just use rejection technique to remove those within the prescribed distance metric(*), or
  2. Generate a regular grid at prescribed distance beginning at a random point; then make a random selection of N of those points.
(*) Is this global or, just as the Q? is worded, successive realizations; could still be R<Dmin between new point and some prior point earlier than the previous?

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by