-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrownian.m
40 lines (40 loc) · 1.28 KB
/
brownian.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function [BSs, UEs] = brownian(K, Q, I, locations, outerRadius)
BSs = zeros(K * Q, 1);
UEs = zeros(K * I, 1);
for k = 1 : K
for q = 1 : Q
x = 0;
y = 0;
while true
x = (rand - 0.5) * 2 * outerRadius;
y = (rand - 0.5) * 2 * outerRadius;
mx = abs(x);
my = abs(y);
valid = true;
if my > outerRadius * sin(pi / 3) || (sqrt(3) * mx + my > outerRadius * sqrt(3))
valid = false;
end
if valid == true
break;
end
end
BSs((k - 1) * Q + q) = x + y * 1j + locations(k);
end
for i = 1 : I
while true
x = (rand - 0.5) * 2 * outerRadius;
y = (rand - 0.5) * 2 * outerRadius;
mx = abs(x);
my = abs(y);
valid = true;
if my > outerRadius * sin(pi / 3) || (sqrt(3) * mx + my > outerRadius * sqrt(3))
valid = false;
end
if valid == true
break;
end
end
UEs((k - 1) * I + i) = x + y * 1j + locations(k);
end
end
return