how do I reference the distance of any points from the center of a uniform distribution in a circle
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
zaxtronix
el 13 de Mayo de 2016
Comentada: Walter Roberson
el 13 de Mayo de 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 comentarios
Respuesta aceptada
Walter Roberson
el 13 de Mayo de 2016
distances = sqrt(x.^2 + y.^2);
2 comentarios
Walter Roberson
el 13 de Mayo de 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)
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!