Plotting random points on a circle

6 visualizaciones (últimos 30 días)
ReturnToCastle
ReturnToCastle el 5 de Mayo de 2020
Comentada: ReturnToCastle el 5 de Mayo de 2020
I am trying to plot 50 random points on a circle with a radius of 500 then store the x, y coordinates of the points in a matrix and calculate each point's distance from the centre of the circle (0,0), any reference I could use or how I can achieve this?

Respuesta aceptada

TADA
TADA el 5 de Mayo de 2020
Assuming you mean inside the circle and not on that circle, because then obviously the distance is 500 Anyway, it is much easier to work in polar coordinates for this task, then the distance is simply the radius we randomize
r = rand(1, 50) * 500;
theta = rand(1, 50) * 2 * pi;
[x,y] = pol2cart(theta, r);
plot(x,y,'o');
  1 comentario
ReturnToCastle
ReturnToCastle el 5 de Mayo de 2020
Yes, I meant inside the circle sorry, I hope your answer helps, thank you!

Iniciar sesión para comentar.

Más respuestas (1)

David Hill
David Hill el 5 de Mayo de 2020
a=2*pi*rand(1,50);
b=500*rand(1,50);
m=[b.*sin(a);b.*cos(a)];

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by