How to generate two random where the distance between is within a range
Show older comments
Let's say we already generate a point randomly,the coordinates of it is fixed, so how to generate anothe randomly which is 10m-60m far away from it ? Can i say the point i want to generate is at a position between two circles whose center are both the previous point?
Accepted Answer
More Answers (1)
Rik
on 8 Dec 2021
0 votes
If you need a uniform distribution you might need to randomly generate pairs of deltaX and deltaY until hypot(deltaX,deltaY) is in your desired range.
If a non-uniform distribution is fine, you can randomly generate a distance and an angle, after which pol2cart allows you to find the corresponding deltaX and deltaY. This will result in a higher density closer to your first point.
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!