forked from hasarieddeen/TeraMIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_TV_THz_Channel.m
126 lines (105 loc) · 4.94 KB
/
Plot_TV_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
114
115
116
117
118
119
120
121
122
123
124
125
126
function Plot_TV_THz_Channel(p, H, h, fd_max_subcarriers ,num_of_plots)
% =========================================================================
% -- Function to generate plots for the frequency and delay domain time-variant THz channel,
% and to check the time correlation between channel taps
% =========================================================================
% -- Function: Plot_TV_THz_Channel(p, H, h, fd_max_subcarriers, num_of_plots)
% -- Input Arguments:
% p: channel struct that contains the channel parameters
% H: H(t,f) TV frequency domain response
% h: h(t,tau) TV delay domain response
% fd_max_subcarriers: maximum Doppler shift for a subcarrier
% num_of_plots: number of plots for time observations
% -- 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;
num_freq_subband = p.Nsubc;
vec_time = randi(p.nSamplesperFrame,1,num_of_plots);
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);
h_temp = h{rx_ind,tx_ind,subc_ind};
for time_ind = 1: length(vec_time)
f = p.freq(:,subc_ind)/1e12;% Frequency vector (THz)
%%%%%% Magnitude of Frequency Domain %%%%%
HH = H(rx_ind,tx_ind,subc_ind,vec_time(time_ind),:);
H_temp1 = fft(h_temp(vec_time(time_ind),:),num_freq_subband);
figure();
plot(f,mag2db(squeeze(abs(HH))),...
'Color','b','Marker','o');hold on;
plot(f,mag2db(abs(H_temp1)),...
'Color','r','Marker','x');
title(strcat('Channel frequency response, subcarrier ',num2str(subc_ind), ...
', (Rx,Tx) pair (',num2str(rx_ind),',',num2str(tx_ind),')'));
xlabel('Frequency (THz)');
ylabel('Path Gain (dB)');
legend('Freq. Domain','From Delay Domain');
hold off;
%%%%%% Magnitude of Delay Domain %%%%%
h1 = ifft(H(rx_ind,tx_ind,subc_ind,vec_time(time_ind),:));
t_vec1 = (1:length(h1))*Ts/1e-9;
t_vec = (1:length(h_temp(vec_time(time_ind),:)))*Ts/1e-9;
figure();
stem(t_vec1, squeeze(abs(h1)), ...
'Color','b',...
'LineStyle','-.','Marker','o');
hold on;
stem(t_vec, squeeze(abs(h_temp(vec_time(time_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
end
%%%%%% Correlation between paths %%%%%
% Select maximum path gain only
t = 0:Ts:Ts*(p.nSamplesperFrame-1);
for rx_ind = 1 : size(h,1)
for tx_ind = 1: size(h,2)
for subc_ind = 1: size(h,3)
h_temp2 = h{rx_ind,tx_ind,subc_ind};
% find max path gain
[~, indx_h_max_g ] = max(abs(h_temp2(1,:)));
h_max_g = squeeze(h_temp2(:,indx_h_max_g));
Acn = xcorr(h_max_g,'biased');
Acn_pos = Acn(p.nSamplesperFrame:end).';
Acn_pos = Acn_pos/max(Acn_pos);
switch p.DopplerSpecShape
case 'Jakes'
Ac_th = besselj(0,2*pi*fd_max_subcarriers(1,subc_ind)*t);
case 'Flat'
Ac_th = sinc(2*fd_max_subcarriers(1,subc_ind)*t);
otherwise
error('The Selected Doppler Spectrum Shape isn''t supported, Options: Jakes, Flat, ...')
end
figure();
plot(t,real(Acn_pos),'b');hold on;
plot(t,real(Ac_th),'r');
title('Autocorrelation Function for Time-Variant Channel');
xlabel('time (msec)');ylabel('Amplitude');
legend('Simulation','Theory');
grid on;hold off;
end
end
end