-
Notifications
You must be signed in to change notification settings - Fork 2
/
getRandMS.m
59 lines (50 loc) · 2.16 KB
/
getRandMS.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [MS] = getRandMS(M = 10, Xc = 0, Yc = 0, Rc = 500)
% Input Arguments:
% M : Number of UEs (defaults tlo 10)
% Rc: Cell Radius in meters (defaults to 500m)
% Output Arguments:
% MS : It is an array of Objects, with parameters:
% uid : Index Number
% x : x co-ordinate (unit is meters)
% y : y co-ordinate (unit is meters)
% d_refcell : Distance from eNB of Referece Cell (unit is meters)
% distance : Array of Distances from BS(eNB)s travelled in Anti-Clock wise sense in 1st Tier.
% Other Parameters---------------------------------
% SINR : Single value (ratio) - WideBand SINR
% SINRk : Array (ratio) - for all RBs
% drate_wb : Wide-Band Expected Data-Rate for ith user at time t => di(t)
% drate_rb_array : Expected Data-Rate for ith user at time t on "k-th" Resource Block(RB)
R = Rc*cos(pi/6);
% Coordinates of all Vertices
X = Rc*[1, cos(pi/3), -cos(pi/3), -1, -cos(pi/3), cos(pi/3)];
Y = Rc*[0, sin(pi/3), sin(pi/3), 0, -sin(pi/3), -sin(pi/3)];
% Surrounding BS vertices
BSx = 2*R*cos( (0:5)*pi/3 );
BSy = 2*R*sin( (0:5)*pi/3 );
x_temp = -Rc + 2*Rc*rand(1,2.5*M);
y_temp = -R + 2*R*rand(1,2.5*M);
% Check for Points inside the Hexagon and outside 1m distance form the BS
flag = inpolygon(x_temp,y_temp,X,Y);
flag2 = ( sqrt(x_temp.^2 + y_temp.^2) > 1);
flag = flag & flag2;
% There should be M Points
if(sum(flag) >= M)
x_coordinate = x_temp(flag);
y_coordinate = y_temp(flag);
x_coordinate = x_coordinate(1:M);
y_coordinate = y_coordinate(1:M);
for index = 1 : M
% Positions, Indices and Distances of each UE
MS(index).uid = index;
MS(index).x = Xc + x_coordinate(index);
MS(index).y = Yc + y_coordinate(index);
MS(index).d_refcell = sqrt( MS(index).x^2 + MS(index).y^2 );
for bs_index = 1:6
MS(index).distance = sqrt( (BSx - MS(index).x ).^2 + (BSy - MS(index).y ).^2 );
end
end
else
disp('Recursive call within getRandMS fn');
MS = getRandMS(M);
end
end