I would like to generate, randomly with uniform distribution, n points such that the distance between any point is greater than some fixed value.
Here is the scenario that I have in MATLAB:
- I have M red points which I generate randomly with uniform distribution as follow: the x-abscissa of the M red points are
xr = rand(1, M)
and the y-ordinate of the M red points areyr = rand(1, M)
. - Also, I have M black points which I generate similarly as the red points, i.e.,
xb = rand(1, M)
andyb = rand(1, M)
. -
Then, I calculate the distances between all the points as follow:
x = [xr, xb]; y = [yr, yb]; D = sqrt(bsxfun(@minus, x, x').^2 + bsxfun(@minus, y, y').^2); d = D(1:M, M + 1:end);
- Now, I have to restrict the distance
d
to be always greater than some given value, sayd0=0.5
.
How to do this?
Aucun commentaire:
Enregistrer un commentaire