how can I plot random points in a random area

조회 수: 16 (최근 30일)
Logical
Logical 2020년 9월 5일
댓글: Walter Roberson 2020년 9월 9일
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.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 9월 5일
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
Tamoor Shafique
Tamoor Shafique 2020년 9월 9일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by