how do I reference the distance of any points from the center of a uniform distribution in a circle
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
zaxtronix
am 13 Mai 2016
Kommentiert: Walter Roberson
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Mai 2016
distances = sqrt(x.^2 + y.^2);
2 Kommentare
Walter Roberson
am 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)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!