how do I reference the distance of any points from the center of a uniform distribution in a circle
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
zaxtronix
le 13 Mai 2016
Commenté : Walter Roberson
le 13 Mai 2016
I have done a uniform distribution of n number of points in a circle, I am stuck in trying to reference the distance of any of those points from the center of the circle to do a further calculation;
My uniform distribution goes as follows:
% radius of the circle
R = 500;
% number of samples
n = 1000;
% my uniform distribution
angle = 2 * pi*(rand(1,n));
r = R * sqrt(rand(1,n));
y = r.*sin(angle);
x = r.*cos(angle);
% the plot of the uniform distribution
plot(x,y,'r.');
0 commentaires
Réponse acceptée
Walter Roberson
le 13 Mai 2016
distances = sqrt(x.^2 + y.^2);
2 commentaires
Walter Roberson
le 13 Mai 2016
By definition, the distance of an object to itself is 0: that is true for all distance metrics, part of the definition of a metric space. In order for a distance function to return a negative value, you would need it to be the case that some point B is even closer to point A then A is to itself. That makes no sense. Distances are never negative.
The way you construct your data, all of the distances will be r
Possibly what you are looking for is direction information. For that, use
atan2(y, x)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!