how to create an random points in desired circle using rand function??

i want to create an one circle and in that i want to create random points and circle around that point at my desired radius,to shoe resource allocation in mobile using matlab

1 件のコメント

Karleen Tur
Karleen Tur 2019 年 3 月 17 日
Hello,
I am doing a project related to the resource allocation in femocell. I am also facing this issue and your thread was very helpful for me, so thank you for that.
I wanted to ask you what exactly you did in your project ? so if any part is common I can reffer to your code of matlab.
If you are intersted in helping please let me know on mahimnat27@gmail.com
Kind Regards,
Mahimna

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

 採用された回答

Hamoon
Hamoon 2015 年 9 月 11 日
編集済み: Hamoon 2015 年 9 月 11 日
You need to generate points which have random angles smaller or equal to 2*pi and random radius smaller or equal to the circle radius, here is the code:
n=100; % number of points that you want
center = [1 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 2*pi*rand(n,1);
r = radius*sqrt(rand(n,1));
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.k')

8 件のコメント

Jayesh Nakum
Jayesh Nakum 2015 年 9 月 11 日
thanksn hamoon now in this program i want to plot an circle by taking take point as an refrence.
Mike Garrity
Mike Garrity 2015 年 9 月 11 日
When transforming random values from one domain to another, you should pay attention to whether you need the results to be uniformly distributed. The "obvious" solution in this case tends to generate points which are denser near the center than they are near the bounds.
Anders Wallin has a good explanation here .
Jayesh Nakum
Jayesh Nakum 2015 年 9 月 11 日
i want to create an one cell area(as coverage area) like one circle and in this i plot random no. as user and also want to plot circle around the user as an indication of the mobile coverage(antenna) capacity to capture in that.
Hamoon
Hamoon 2015 年 9 月 11 日
Thank you Mike, that was great, so I change it in the code.
Hamoon
Hamoon 2015 年 9 月 11 日
@Jayesh: You want to draw a circle? just perform these changes to the code:
angle = 0:.01:2*pi;
r = radius;
and also in the end:
plot(X,Y)
Jayesh Nakum
Jayesh Nakum 2015 年 9 月 11 日
thanks sir but i want to draw circle at random point that r shown in above code.
Hamoon
Hamoon 2015 年 9 月 11 日
When you have one graph and you want to add another graph to it you can use "hold on", like this:
plot(x1,y1);
hold on
plot(x2,y2);
Priyam Shah
Priyam Shah 2020 年 9 月 25 日
I have an extra question added to the solution as to how to repeat this 1000 times and plot a randomly selected single instance on the graph

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

質問済み:

2015 年 9 月 11 日

コメント済み:

2020 年 9 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by