-
Notifications
You must be signed in to change notification settings - Fork 6
/
fit_6_12_15.m
157 lines (134 loc) · 5.39 KB
/
fit_6_12_15.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
clear all
%close all
altitude = 12;
load(strcat('dataset_min_pathloss_alt_', num2str(altitude), '.mat'))
min_pathloss_12 = [];
for el = 1:numel(pl_struct)
min_pathloss_12 = [min_pathloss_12, pl_struct(el).min];
end
distance_12 = distance;
pl_struct_12 = pl_struct;
altitude = 15;
load(strcat('dataset_min_pathloss_alt_', num2str(altitude), '.mat'))
min_pathloss_15 = [];
for el = 1:numel(pl_struct)
min_pathloss_15 = [min_pathloss_15, pl_struct(el).min];
end
distance_15 = distance;
pl_struct_15 = pl_struct;
altitude = 6;
load(strcat('dataset_min_pathloss_alt_', num2str(altitude), '.mat'))
min_pathloss_6 = [];
for el = 1:numel(pl_struct)
min_pathloss_6 = [min_pathloss_6, pl_struct(el).min];
end
distance_6 = distance;
pl_struct_6 = pl_struct;
pl_struct_join = struct('dist', [], 'alt', [], 'min', [], 'beam_diffs', [], ...
'beam_diffs_deg_tx', [], 'beam_diffs_deg_rx', []);
% join
tmp_index = 1;
for dir_index = 1:numel(pl_struct_6)
pl_struct_join(tmp_index).dist = pl_struct_6(dir_index).dist;
pl_struct_join(tmp_index).alt = 6;
pl_struct_join(tmp_index).min = pl_struct_6(dir_index).min;
pl_struct_join(tmp_index).beam_diffs = pl_struct_6(dir_index).beam_diffs;
pl_struct_join(tmp_index).beam_diffs_deg_tx = pl_struct_6(dir_index).beam_diffs_deg_tx;
pl_struct_join(tmp_index).beam_diffs_deg_rx = pl_struct_6(dir_index).beam_diffs_deg_rx;
tmp_index = tmp_index + 1;
end
for dir_index = 1:numel(pl_struct_12)
pl_struct_join(tmp_index).dist = pl_struct_12(dir_index).dist;
pl_struct_join(tmp_index).alt = 12;
pl_struct_join(tmp_index).min = pl_struct_12(dir_index).min;
pl_struct_join(tmp_index).beam_diffs = pl_struct_12(dir_index).beam_diffs;
pl_struct_join(tmp_index).beam_diffs_deg_tx = pl_struct_12(dir_index).beam_diffs_deg_tx;
pl_struct_join(tmp_index).beam_diffs_deg_rx = pl_struct_12(dir_index).beam_diffs_deg_rx;
tmp_index = tmp_index + 1;
end
for dir_index = 1:numel(pl_struct_15)
pl_struct_join(tmp_index).dist = pl_struct_15(dir_index).dist;
pl_struct_join(tmp_index).alt = 15;
pl_struct_join(tmp_index).min = pl_struct_15(dir_index).min;
pl_struct_join(tmp_index).beam_diffs = pl_struct_15(dir_index).beam_diffs;
pl_struct_join(tmp_index).beam_diffs_deg_tx = pl_struct_15(dir_index).beam_diffs_deg_tx;
pl_struct_join(tmp_index).beam_diffs_deg_rx = pl_struct_15(dir_index).beam_diffs_deg_rx;
tmp_index = tmp_index + 1;
end
distance = 6:3:42;
%% CI
% eq(7) http://www.5gworkshops.com/5GCMSIG_White%20Paper_r2dot3.pdf
c = 2.997925e8; %[m/s] - speed of light
f = 60.48e9; % Hz
fpl_reference_1m = 20 * log10((4 * pi * 1 * f) / c );
x = [];
y = [];
index = 1;
for dir_index = 1:numel(pl_struct_join)
dist = pl_struct_join(dir_index).dist;
if ~isempty(pl_struct_join(dir_index).min)
minima = pl_struct_join(dir_index).min;
support = 10*log10(pl_struct_join(dir_index).dist * ones(length(minima), 1));
y(index:(index + length(minima) - 1)) = minima - fpl_reference_1m;
x(index:(index + length(minima) - 1)) = support;
index = index + length(minima);
end
end
X = x.';
B_ci = X \ y';
fit_line_ci_all = fpl_reference_1m + B_ci * 10 * log10(distance);
% compute std dev
diff = [];
for dir_index = 1:numel(pl_struct_join)
dist = pl_struct_join(dir_index).dist;
diff(dir_index) = pl_struct_join(dir_index).min - (fpl_reference_1m + B_ci * 10 * log10(dist));
end
sigma_sq_db_ci_all = sum(diff.^2)/length(diff);
%% ABG
% eq(10) http://www.5gworkshops.com/5GCMSIG_White%20Paper_r2dot3.pdf
% we cannot distinguish beta and gamma, or, at least, we need to fix one of
% the two
x = [];
y = [];
index = 1;
for dir_index = 1:numel(pl_struct_join)
dist = pl_struct_join(dir_index).dist;
if ~isempty(pl_struct_join(dir_index).min)
minima = pl_struct_join(dir_index).min;
support = 10*log10(pl_struct_join(dir_index).dist * ones(length(minima), 1));
y(index:(index + length(minima) - 1)) = minima;
x(index:(index + length(minima) - 1)) = support;
index = index + length(minima);
end
end
X = [ones(1, length(x)); x].';
B_abg = X \ y';
fit_line_abg_all = B_abg(1) + B_abg(2) * 10 * log10(distance);
% compute std dev
diff = [];
for dir_index = 1:numel(pl_struct_join)
dist = pl_struct_join(dir_index).dist;
diff(dir_index) = pl_struct_join(dir_index).min - ( B_abg(1) + B_abg(2) * 10 * log10(dist));
end
sigma_sq_db_abg_all = sum(diff.^2)/length(diff);
%% plot
markers = {'+','o','*','x','v','d','^','s','>','<'};
fpl = 20 * log10((4 * pi * distance * f) / c );
figure, hold on,
plot(distance, fit_line_ci_all, strcat('-'), 'DisplayName', strcat('CI, 6-15'))
plot(distance, fit_line_abg_all, strcat('-.'), 'DisplayName', strcat('ABG, 6-15'))
scatter(distance_12, min_pathloss_12, markers{1}, 'DisplayName', strcat('h = 12'))
scatter(distance_6, min_pathloss_6, markers{2}, 'DisplayName', strcat('h = 15'))
scatter(distance_15, min_pathloss_15, markers{3}, 'DisplayName', strcat('h = 6'))
plot(distance, fpl, strcat(':', markers{2 + 2}), 'DisplayName', 'Free space pathloss')
tikz_enable = false;
if(tikz_enable)
matlab2tikz('ci_abg_all.tex', 'width', '\fwidth', 'height', '\fheight')
end
legend('-DynamicLegend')
grid on
xlabel('UAV-to-UAV distance')
ylabel('Pathloss [dB]')
distance_all = distance;
save('dataset_best_fit_6-15.mat', 'distance_all', 'fit_line_abg_all', 'fit_line_ci_all')
save('dataset_min_pathloss_alt_6-15.mat', 'distance_all', 'pl_struct_join', 'fit_line_ci_all')