-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vehicle_connected_UEs.m
112 lines (98 loc) · 5.78 KB
/
Vehicle_connected_UEs.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function UEs = Vehicle_connected_UEs(LTE_config, UEs)
% This function is to setting broadcast coommunication range
for u=1:length(UEs)
UEs(u).connected_UEs=network_elements.UE;
end
%%
for u_=1:20
UEs(u_).neighbors_UEs = UEs([1:(u_-1) (u_+1):20]);
j=1;
% Calculate the distance b/t Broadcast UE & Attached UE
for i=1:19
UE_distance(i)=sqrt((UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1)).*(UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1))...
+(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)).*(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)));
% calculate the relative Speed b/t Broadcast UE & Attached UE
if UEs(u_).walking_model.direction == UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=0;
end
if UEs(u_).walking_model.direction == - UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=2*LTE_config.UE_speed;
end
if UE_distance(i) < 150
UEs(u_).connected_UEs(j)= UEs(u_).neighbors_UEs(i);
%UEs(u_).connected_UEs(j).attached_UE=UEs(u_);
%UEs(u_).connected_UEs(j).UE_distance=UE_distance(i);
j=j+1;
end
end
end
%%
for u_=21:44
UEs(u_).neighbors_UEs = UEs([21:(u_-1) (u_+1):44]);
j=1;
for i=1:23
UE_distance1(i)=sqrt((UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1)).*(UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1))...
+(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)).*(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)));
% calculate the relative Speed b/t Broadcast UE & Attached UE
if UEs(u_).walking_model.direction == UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=0;
end
if UEs(u_).walking_model.direction == - UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=2*LTE_config.UE_speed;
end
if UE_distance1(i) < 150
UEs(u_).connected_UEs(j)= UEs(u_).neighbors_UEs(i);
%UEs(u_).connected_UEs(j).attached_UE=UEs(u_);
%UEs(u_).connected_UEs(j).UE_distance=UE_distance(i);
j=j+1;
end
end
end
%%
for u_=45:76
UEs(u_).neighbors_UEs = UEs([45:(u_-1) (u_+1):76]);
j=1;
for i=1:31
UE_distance2(i)=sqrt((UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1)).*(UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1))...
+(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)).*(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)));
% calculate the relative Speed b/t Broadcast UE & Attached UE
if UEs(u_).walking_model.direction == UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=0;
end
if UEs(u_).walking_model.direction == - UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=2*LTE_config.UE_speed;
end
% connected UEs for get broadcast message
if UE_distance2(i) < 150
UEs(u_).connected_UEs(j)= UEs(u_).neighbors_UEs(i);
%UEs(u_).connected_UEs(j).attached_UE=UEs(u_);
%UEs(u_).connected_UEs(j).UE_distance=UE_distance(i);
j=j+1;
end
end
end
%%
for u_=77:82
UEs(u_).neighbors_UEs = UEs([77:(u_-1) (u_+1):82]);
j=1;
% Calculate the distance b/t Broadcast UE & Attached UE
for i=1:5
UE_distance3(i)=sqrt((UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1)).*(UEs(u_).pos(1)-UEs(u_).neighbors_UEs(i).pos(1))...
+(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)).*(UEs(u_).pos(2)-UEs(u_).neighbors_UEs(i).pos(2)));
% calculate the relative Speed b/t Broadcast UE & Attached UE
if UEs(u_).walking_model.direction == UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=0;
end
if UEs(u_).walking_model.direction == - UEs(u_).neighbors_UEs(i).walking_model.direction
UEs(u_).neighbors_UEs(i).relative_speed=2*LTE_config.UE_speed;
end
% connected UEs for get broadcast message
if UE_distance3(i) < 150
UEs(u_).connected_UEs(j)= UEs(u_).neighbors_UEs(i);
%UEs(u_).connected_UEs(j).attached_UE=UEs(u_);
%UEs(u_).connected_UEs(j).UE_distance=UE_distance(i);
j=j+1;
end
end
end
end