how can I plot random points in a random area

7 ビュー (過去 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
Walter Roberson
Walter Roberson 2020 年 9 月 9 日

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by