-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdemo.m
executable file
·88 lines (64 loc) · 2.06 KB
/
demo.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
% demonstratioin code for fast hybrid precoding algorithm for OFDM.
clear
clc
close all;
L = 128; % # of multi-carriers
Ns = 4; % # of streams
NRF = 5; % # of RF
Nc = 5; % # of clusters
Nray = 10; % # of rays in each cluster
Nt = 144; % # of transmit antennas
Nr = 36; % # of receive antennas
angle_sigma = 10/180*pi; %standard deviation of the angles in azimuth and elevation both of Rx and Tx
gamma = sqrt((Nt*Nr)/(Nc*Nray)); %normalization factor
sigma = 1; %according to the normalization condition of the H
realization = 10;
SNR_dB = -15:5:10;
SNR = 10.^(SNR_dB./10);
smax = length(SNR);
% set params for generate_OFDM_matrices
clear params;
params.Ns = Ns;
params.NRF = NRF;
params.Nc = Nc;
params.Nray = Nray;
params.Nt = Nt;
params.Nr = Nr;
params.angle_sigma = angle_sigma;
params.gamma = gamma;
params.sigma = sigma;
params.realization = realization;
params.L = L;
RM = zeros(smax, realization);
%% main loop with realization times
tic
for reali = 1:realization
%% generate matrices for OFDM
[Fopt, Wopt, H, At, Ar, FRF_enc, FRF_dec] = generate_OFDM_matrices(params);
%% perform fast hybrid precoding algorithm
[FRFM, FBBM] = fast_hybrid_precoding_wrapper_OFDM( Fopt, NRF, 0 );
for l = 1:L
FBBM(:,:,l) = sqrt(Ns) * FBBM(:,:,l) / norm(FRFM * FBBM(:,:,l),'fro');
end
[WRFM, WBBM] = fast_hybrid_precoding_wrapper_OFDM( Wopt, NRF, 0 );
%% Calculate the spectral efficiency
for l = 1:L
for s = 1:smax
RM(s,reali) = RM(s,reali) + log2(det(eye(Ns) + SNR(s)/Ns * pinv(WRFM * WBBM(:,:,l)) * H(:,:,l) * FRFM * FBBM(:,:,l) * FBBM(:,:,l)' * FRFM' * H(:,:,l)' * WRFM * WBBM(:,:,l)))/L;
end
end
fprintf('%04d: %s\n', reali, real(RM(1,reali)));
end
toc
sum(RM,2)/realization
%% plotting
figure
fs = 20;
linewidth = 2;
plot(SNR_dB,sum(RM,2)/realization, '-or', 'LineWidth', linewidth)
grid on
ax1 = gca;
set(ax1,'FontSize',fs);
xlabel('SNR [dB]')
ylabel('Spectral efficiency (bits/s/Hz)')
legend('Fast hybrid precoding algorithm', 'Location', 'northwest')