how can I plot random points in a random area

7 visualizaciones (últimos 30 días)
Logical
Logical el 5 de Sept. de 2020
Comentada: Walter Roberson el 9 de Sept. de 2020
Hi everyone,
Thank you all who are already trying to help me and appologies for keep asking questions.
In this thread I want to learn from experts following:
1.How to Plot 'n' number of points randomly in one of the following 3D spaces/regions i.e. (cube/3d Rectangular/Speherical).
2.the code should randomly pick one of the spaces each timeand then plot 'n' random points uniformly in that space.
3.once plotted how can I obtain the location information of each point centrally? May be at an additional point/gateway at the origin.
I know there are many questions within one question but it is important to explain to someone who is trying to help you what exactly you wish to do. Any help for even a partial code would be appretiated.
I have already accomplished how to distribute random points on a 3d rectangular plot but the point which I am unsure about how to do the same when the dimentions of plot are to be randomly picked from a set of polar and rectangular coordinates.

Respuestas (1)

Ameer Hamza
Ameer Hamza el 5 de Sept. de 2020
Here is an example to plot points in spherical coordinates
n = 1000; % number of points
az = rand(1, n)*2*pi; % azimuth angle in range [0, 2*pi]
elev = rand(1, n)*2*pi - pi; % elevation angle in range [-pi, pi]
r = rand(1, n)*2; % radius in range [0, 3]
[x, y, z] = sph2cart(az, elev, r);
plot3(x, y, z, '+')
  9 comentarios
Tamoor Shafique
Tamoor Shafique el 9 de Sept. de 2020
You are right I have to modify the code for generating points inside a spherical boundary but switch command helped me to choose one of the three random cases

Iniciar sesión para comentar.

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by