how to generate random point that have fix distance between each point
조회 수: 3 (최근 30일)
이전 댓글 표시
i can generate random point within a specific area
like this
x=rand(1,100)*5
y=rand(1,100)*5
scatter(x,y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/666990/image.jpeg)
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?
댓글 수: 0
채택된 답변
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)
댓글 수: 0
추가 답변 (1개)
dpb
2021년 6월 27일
I see two possible simple alternatives--
- Just use rejection technique to remove those within the prescribed distance metric(*), or
- 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?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!