-
Notifications
You must be signed in to change notification settings - Fork 6
/
fit_6.m
94 lines (75 loc) · 2.76 KB
/
fit_6.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
clear all
close all
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
%% 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)
dist = pl_struct(dir_index).dist;
if ~isempty(pl_struct(dir_index).min)
minima = pl_struct(dir_index).min;
support = 10*log10(pl_struct(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_6 = fpl_reference_1m + B_ci * 10 * log10(distance);
% compute std dev
for dir_index = 1:numel(pl_struct)
dist = pl_struct(dir_index).dist;
diff(dir_index) = pl_struct(dir_index).min - (fpl_reference_1m + B_ci * 10 * log10(dist));
end
sigma_sq_db_ci_6 = 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)
dist = pl_struct(dir_index).dist;
if ~isempty(pl_struct(dir_index).min)
minima = pl_struct(dir_index).min;
support = 10*log10(pl_struct(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_6 = B_abg(1) + B_abg(2) * 10 * log10(distance);
% compute std dev
for dir_index = 1:numel(pl_struct)
dist = pl_struct(dir_index).dist;
diff(dir_index) = pl_struct(dir_index).min - ( B_abg(1) + B_abg(2) * 10 * log10(dist));
end
sigma_sq_db_abg_6 = 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_6, strcat('-'), 'DisplayName', strcat('CI, h = ', num2str(altitude)))
plot(distance, fit_line_abg_6, strcat('-.'), 'DisplayName', strcat('ABG, h = ', num2str(altitude)))
scatter(distance, min_pathloss_6, markers{1}, 'DisplayName', strcat('h = ', num2str(altitude)))
plot(distance, fpl, strcat(':', markers{2 + 2}), 'DisplayName', 'Free space pathloss')
legend('-DynamicLegend')
grid on
xlabel('UAV-to-UAV distance')
ylabel('Pathloss [dB]')
distance_6 = distance;
save('dataset_best_fit_6.mat', 'distance_6', 'fit_line_abg_6', 'fit_line_ci_6')