-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunction_Amn.m
80 lines (59 loc) · 3.12 KB
/
function_Amn.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
function [A_mn_sum, A_mn_matrix]=function_Amn(p_BS, centers_IRS, p_vehicle_trajectory, total_time, dx, dy, isotropic)
% [A_mn_sum, A_mn_matrix]=function_Amn(p_BS, centers_IRS, p_vehicle_trajectory, total_time, dx, dy, isotropic)
% Author: Ke(Ken)WANG from Macao Polytechnic Institute
% Email: ke.wang@ipm.edu.mo, kewang0225@gmail.com
% Update infomation: v0.1(2020/11/20), v0.2(2021/08/26), v0.3(2021/09/04)
%
% This function aims to calculate A_mn, i.e., eq(6) in the GC paper 2021
%
% License: This code is licensed under the GPLv2 license. If you in any way
% use this code for research that results in publications, please cite our
% original article.
%
% Example:
%
% TBD
global c0 fc;
lambda_c = c0/fc;
%Note that p2 is IRS and p1 is BS. This gain is $G_T^{mn}$
%This is the gain from BS to IRS, that means this gain always euqals to 1
%since we assume the transceiver is isotropic
G_BS_to_IRS_direction = function_antenna_gain_TR(p_BS, centers_IRS);
%This gain is $G_{mn}^T$. If the IRS is isotropic, the gain is 1, otherwise we use
%"function_gain_IRS" to calculate the gain.
G_IRS_to_BS_direction = function_gain_IRS_v2(centers_IRS, p_BS, dx, dy, isotropic);
%The first half part of eq(6)
A_BS_IRS = lambda_c/(4*pi) * sqrt(G_BS_to_IRS_direction.*G_IRS_to_BS_direction)./vecnorm((centers_IRS-p_BS)');
A_mn_sum = [];
A_IRS_Vehicle = [];
A_mn_matrix = []; % size(A_mn_matrix) = total_time x M*N
G_Vehicle_to_IRS_direction=[];
G_IRS_to_Vehicle_direction=[];
%This for-loop aims to calculate $G_R^{mn}(t)$ and $G_{mn}^R(t)$ in eq(6)
%and its above content in the GC paper 2021
for t = 1 : total_time
%This is the gain from Vehicle to IRS, $G_R^{mn}(t)$. That means this gain always euqals to 1
%since we assume the transceiver is isotropic
temp_G_Vehicle_to_IRS_direction = function_antenna_gain_TR(p_vehicle_trajectory(t,:), centers_IRS);
G_Vehicle_to_IRS_direction =[G_Vehicle_to_IRS_direction; temp_G_Vehicle_to_IRS_direction];
%This is the gain from IRS to Vehicle, $G_{mn}^R(t)$. If the IRS is isotropic, the gain is 1, otherwise we use
%"function_gain_IRS" to calculate the gain.
temp_G_IRS_to_Vehicle_direction = function_gain_IRS_v2(centers_IRS , p_vehicle_trajectory(t,:), dx, dy, isotropic);
G_IRS_to_Vehicle_direction =[G_IRS_to_Vehicle_direction; temp_G_IRS_to_Vehicle_direction];
end
%This for-loop aims to calculate $A_{m,n}$, i.e., eq(6), the GC paper 2021
for t = 1 : total_time
%The second half part of eq(6)
A_IRS_Vehicle = ...
lambda_c/(4*pi) * sqrt(G_Vehicle_to_IRS_direction(t,:)...
.*G_IRS_to_Vehicle_direction(t,:)) ./ vecnorm((p_vehicle_trajectory(t,:)-centers_IRS).');
%The entire eq(6) in the GC paper 2021
temp_A_mn_sum = sum(A_BS_IRS .* A_IRS_Vehicle);
A_mn_sum = [A_mn_sum; temp_A_mn_sum];
%We also want to get a matrix that contains the exact gain of every
%element during total time. It helps calculate the approximation of the
%SE
temp_A_mn_matrix = A_BS_IRS .* A_IRS_Vehicle;
A_mn_matrix = [A_mn_matrix; temp_A_mn_matrix];
end
end