forked from hasarieddeen/TeraMIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_TIV_THz_Channel.m
113 lines (99 loc) · 4.39 KB
/
Plot_TIV_THz_Channel.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
function Plot_TIV_THz_Channel(p, H, h)
% =========================================================================
% -- Function to generate plots for the frequency and delay domain time-invariant THz channel
% =========================================================================
% -- Function: Plot_TIV_THz_Channel(p, H, h)
% -- Input Arguments:
% p: channel struct that contains the channel parameters
% H: H(f) TIV frequency domain response
% h: h(tau) TIV delay domain response
% -- Output Arguments:
%=================================================
% -- (c) 2021 Simon Tarboush, Hadi Sarieddeen, Hui Chen,
% Mohamed Habib Loukil, Hakim Jemaa,
% Mohamed-Slim Alouini, Tareq Y. Al-Naffouri
% =========================================================================
% S. Tarboush, H. Sarieddeen, H. Chen, M.-H. Loukil, H. Jemaa, M.-S. Alouini, and T. Y. Al-Naffouri,
% "TeraMIMO: A channel simulator for wideband ultra-massive MIMO terahertz communications,"
% arXivpreprint arXiv:2104.11054, 2021.
% =========================================================================
Ts = 1/p.BW_sub;
rx_ind = 1;
tx_ind = 1;
if size(H,3) <= 3
slec_ind = 1:size(H,3);
else
slec_ind = [1, ceil(size(H,3)/2) size(H,3)];
end
for indx = 1: length(slec_ind)
subc_ind = slec_ind(indx);
f = p.freq(:,subc_ind)/1e9;% Frequency vector (THz)
%%%%%% Magnitude of Frequency Domain %%%%%
HH = abs(H(rx_ind,tx_ind,subc_ind,:));
H_temp1 = abs(fft(h{rx_ind,tx_ind,subc_ind},size(H,4)));
figure();
plot(f,mag2db(squeeze(HH)),...
'Color','b');hold on;
plot(f,mag2db(squeeze(H_temp1)),...
'Color','r');
title(strcat('Channel frequency response, subcarrier ',num2str(subc_ind), ...
', (Rx,Tx) pair (',num2str(rx_ind),',',num2str(tx_ind),')'));
xlabel('Frequency (GHz)');
ylabel('Path Gain (dB)');
legend('Frequency Domain','From Delay Domain');
hold off;
%%%%%% Phase of Frequency Domain %%%%%
HH_ph = angle(H(rx_ind,tx_ind,subc_ind,:));
H_temp1_ph = angle(fft(h{rx_ind,tx_ind,subc_ind},size(H,4)));
figure();
plot(f,rad2deg(squeeze(HH_ph)),...
'Color','b','LineStyle','-.','Marker','o');hold on;
plot(f,rad2deg(squeeze(H_temp1_ph)),...
'Color','r','LineStyle','--','Marker','*');
title(strcat('Channel phase response, subcarrier ',num2str(subc_ind), ...
', (Rx,Tx) pair (',num2str(rx_ind),',',num2str(tx_ind),')'));
xlabel('Frequency (GHz)');
ylabel('Phase Response (Degree)');
legend('Frequency Domain','From Delay Domain');
hold off;
%%%%%% PDP of Delay Domain %%%%%
h1 = ifft(H(rx_ind,tx_ind,subc_ind,:));
t_vec = (1:length(h{rx_ind,tx_ind,subc_ind}))*Ts/1e-9;
t_vec1 = (1:length(h1))*Ts/1e-9;
figure();
stem(t_vec1, squeeze(mag2db(abs(h1))), ...
'Color','b',...
'LineStyle','-.','Marker','o');
hold on;
stem(t_vec, squeeze(mag2db(abs(h{rx_ind,tx_ind,subc_ind}))),...
'Color','r', ...
'LineStyle','--','Marker','*');
title(strcat('Channel power delay profile, subcarrier ',num2str(subc_ind), ...
', (Rx,Tx) pair (',num2str(rx_ind),',',num2str(tx_ind),')'));
xlabel('$\tau (nsec) $','Interpreter','latex');
ylabel('PDP (dB)');
set(gca, 'Ydir', 'reverse');
legend('From Freq. Domain','Delay Domain');
hold off;
%%%%%% Magnitude of Delay Domain %%%%%
h1 = ifft(H(rx_ind,tx_ind,subc_ind,:));
t_vec = (1:length(h{rx_ind,tx_ind,subc_ind}))*Ts/1e-9;
t_vec1 = (1:length(h1))*Ts/1e-9;
figure();
stem(t_vec1, squeeze(abs(h1)), ...
'Color','b',...
'LineStyle','-.','Marker','o');
hold on;
stem(t_vec, squeeze(abs(h{rx_ind,tx_ind,subc_ind})),...
'Color','r', ...
'LineStyle','--','Marker','*');
title(strcat('Channel delay-domain, subcarrier ',num2str(subc_ind), ...
', (Rx,Tx) pair (',num2str(rx_ind),',',num2str(tx_ind),')'));
xlabel('$\tau (nsec) $','Interpreter','latex');
ylabel('Magnitude');
legend('From Freq. Domain','Delay Domain');
hold off;
end