how to distribute users uniformaly inside rectangle
5 次查看(过去 30 天)
显示 更早的评论
I have a rectangle in xy plane eg. R=50 , how can I distribute users inside the rectangle in a uniform distribution and after that how can I find the xy coordination of each user inside the rectangle. thanks
2 个评论
采纳的回答
KSSV
2017-5-19
L = 1 ; % length of the rectnagle
B = 2 ; % breadth of the rectangle
Rect = [ 0 0 ; L 0 ; L B ; 0 B ; 0 0] ;
N = 1000 ;
a1 = 0;
b1 = L;
x = (b1-a1).*rand(N,1) + a1;
a2 = 0;
b2 = B;
y = (b2-a2).*rand(N,1) + a2;
plot(Rect(:,1),Rect(:,2),'r')
hold on
plot(x,y,'.b')
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!