forked from hasarieddeen/TeraMIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
824cd68
commit aa5b0a3
Showing
1 changed file
with
57 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
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 | ||
|
@@ -18,8 +17,8 @@ function Plot_TV_THz_Channel(p, H, h, fd_max_subcarriers ,num_of_plots) | |
|
||
% ========================================================================= | ||
|
||
% -- (c) 2021 Simon Tarboush, Hadi Sarieddeen, Hui Chen, | ||
% Mohamed Habib Loukil, Hakim Jemaa, | ||
% -- (c) 2021 Simon Tarboush, Hadi Sarieddeen, Hui Chen, | ||
% Mohamed Habib Loukil, Hakim Jemaa, | ||
% Mohamed-Slim Alouini, Tareq Y. Al-Naffouri | ||
|
||
% -- e-mail: [email protected]; [email protected]; [email protected]; | ||
|
@@ -28,7 +27,7 @@ function Plot_TV_THz_Channel(p, H, h, fd_max_subcarriers ,num_of_plots) | |
|
||
% ========================================================================= | ||
|
||
% S. Tarboush, H. Sarieddeen, H. Chen, M.-H. Loukil, H. Jemaa, M.-S. Alouini, and T. 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. | ||
|
||
|
@@ -38,73 +37,78 @@ function Plot_TV_THz_Channel(p, H, h, fd_max_subcarriers ,num_of_plots) | |
num_freq_subband = p.Nsubc; | ||
vec_time = randi(p.nSamplesperFrame,1,num_of_plots); | ||
|
||
for rx_ind = 1 : size(h,1) | ||
for tx_ind = 1: size(h,2) | ||
for subb_ind = 1: size(h,3) | ||
|
||
h_temp = h{rx_ind,tx_ind,subb_ind}; | ||
|
||
for time_ind = 1: length(vec_time) | ||
|
||
f = p.freq(:,subb_ind)/1e12;% Frequency vector (THz) | ||
|
||
%%%%%% Magnitude of Frequency Domain %%%%% | ||
HH = H(rx_ind,tx_ind,subb_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('Channel Frequency Response'); | ||
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,subb_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('Delay-Domain Channel'); % Impulse response | ||
xlabel('$\tau (nsec) $','Interpreter','latex'); | ||
ylabel('Magnitude'); | ||
legend('From Freq. Domain','Delay Domain'); | ||
hold off; | ||
|
||
end | ||
end | ||
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 subb_ind = 1: size(h,3) | ||
for subc_ind = 1: size(h,3) | ||
|
||
h_temp2 = h{rx_ind,tx_ind,subb_ind}; | ||
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,subb_ind)*t); | ||
Ac_th = besselj(0,2*pi*fd_max_subcarriers(1,subc_ind)*t); | ||
case 'Flat' | ||
Ac_th = sinc(2*fd_max_subcarriers(1,subb_ind)*t); | ||
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 | ||
|