how to create an random points in desired circle using rand function??
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jayesh Nakum
am 11 Sep. 2015
Kommentiert: Priyam Shah
am 25 Sep. 2020
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 Kommentar
Karleen Tur
am 17 Mär. 2019
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
Akzeptierte Antwort
Hamoon
am 11 Sep. 2015
Bearbeitet: Hamoon
am 11 Sep. 2015
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 Kommentare
Hamoon
am 11 Sep. 2015
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
am 25 Sep. 2020
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!