-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.m
53 lines (45 loc) · 1.54 KB
/
User.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
classdef User
%USER Representation of a User Equipment Terminal
properties
x % Horizontal location in cell
y % Vertical location in cell
id % Unique identifier
d2d %Specifies if the user is d2d user
head = false %Specifies if the user is a head of d2d
neighbor = 0 %Specifies the users neigbor id if d2d
blocks %Vector of blocks in use by a users
nrOfBlocks = 0 %Amount of resource blocks held by user
sinr = 0
recievedPower = 0
interferencePowerD2D = 0
interferencePowerBS = 0
throughput = 0
end
methods
%Constructor
function obj = User(id, x, y, d2d)
obj.id = id;
obj.x = x;
obj.y = y;
obj.d2d = d2d;
end
function obj = setD2DProperties(obj, isHead, neighborId)
obj.head = isHead;
obj.neighbor = neighborId;
end
function obj = addBlock(obj, blockId)
obj.blocks(obj.nrOfBlocks + 1) = blockId;
obj.nrOfBlocks = obj.nrOfBlocks + 1;
end
function obj = calculateSINR(obj)
if (obj.nrOfBlocks ~= 0)
obj.sinr = obj.recievedPower - pow2db(db2pow(obj.interferencePowerD2D-30) + db2pow(obj.interferencePowerBS-30))+ 30;
else
obj.sinr = 0;
end
end
function obj = calculateThroughput(obj)
obj.throughput = log2(1+ db2pow(obj.sinr-30));
end
end
end