Random uniform distribution of nodes within a radius

2 ビュー (過去 30 日間)
sree chak
sree chak 2020 年 9 月 2 日
回答済み: SUMITHRA SOFIA 2020 年 12 月 9 日
Hello,
I am evaluating a localization technique and need to set up a detection range such that a sensor will be in the middle with a max radius of 20m out.
I have a set of N nodes. And I'd like them to be distributed uniformly and randomly within an area (on x,y plane (z component set to 0)) with a radius of 20m.
I know the rand function is used to generate random uniform numbers, but how do I ensure that the positions generated stay within the detection range of 20m radius

回答 (2 件)

Dana
Dana 2020 年 9 月 2 日
編集済み: Dana 2020 年 9 月 2 日
I had a previous answer here but it occurred to me afterwards that the result wouldn't actually be uniform within the disk. Here's the correct way to do it. The following code draws 1,000,000 points uniformly from the disk with radius 20 and plots a histogram so you can visually verify uniformity.
n = 1000000;
maxR = 20;
Th = 2*pi*rand(n,1);
R2 = maxR^2*rand(n,1);
x = sqrt(R2).*cos(Th);
y = sqrt(R2).*sin(Th);
figure
histogram2(x,y)

SUMITHRA SOFIA
SUMITHRA SOFIA 2020 年 12 月 9 日
if u distribute like this how will u automatically place the sensor node in centre , do u retrive any data from the plot u generate

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by