-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbe_v2.m
297 lines (247 loc) · 8.65 KB
/
be_v2.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
clc
clear all
close all
%% input specifications
ncb = 7e7; % nominal channel bandwidth
sf = 8e7; % sampling frequency
ts = 160e-6; % OFDM symbol duration
fd = 14; % maximum doppler freq
N = 1024;
%% input data
e1=zeros(8,1); e2=zeros(8,1); e3=zeros(8,1);
for k=1:100
j=1;
for SNR_db = -5:5:15
SNR = 10^(SNR_db/10); % Absolute SNR
lcp = 32; % Lcp = 32
pdp = exp(-([0:lcp]/2)); % exponential PDP
P = 12; % number of pilots
%% normalization of the energy for the QPSK constelation
temp = 0:3; % possible symbols
temp = qammod(temp,4); % modulated symbols
temp = abs(temp).^2; % power of each point in the constellation
temp = mean(temp); % average energy of the constellation
mod_norm = 1/sqrt(temp); % normaliztion factor
%% Get the channel
% Convert variance values to linear scale
sigma= pdp;
% Find the sum of sigma and normalize
sm = sum(sigma);
sigma = sigma/sm;
% scale the gains
for i=1:lcp
a(i)=(sigma(i)/2)*randn(1)+1j*(sigma(i)/2)*rand(1);
end
H = (1/sqrt(N))*fft(a,1024)';
HH = H(1:108,1);
H_p = [HH(1,1) HH(2,1) HH(55,1) HH(56,1) HH(45,1) HH(46,1) HH(99,1) HH(100,1) HH(35,1) HH(36,1) HH(89,1) HH(90,1)]';
% plot(ss);
%n=10.*log10(s.^2);
%% input data generation
% symbol generation for QPSK modulation
X = randi(4,1024,1)-1; % generation of 12x1 matrix of data symbols
% QPSK modulation
X1 = mod_norm*qammod(X,4);
X2 =(1/sqrt(N))* fft(X1,1024);
XX2 = X2(1:108,1);
Xp = [XX2(1,1) XX2(2,1) XX2(55,1) XX2(56,1) XX2(45,1) XX2(46,1) XX2(99,1) XX2(100,1) XX2(35,1) XX2(36,1) XX2(89,1) XX2(90,1)];
X_p = diag(Xp);
% %% channel estimates from ML estimator
% Hcap_ml = zeros(5,2,1);
%% Gaussian noise covariance
sigma2 = 1/SNR;
C_v = sigma2*eye(P);
%% Y_p is known at the output
V_p =(sigma2/2).*randn(12,1)+1j*(sigma2/2)*rand(12,1);
Y_p = X_p*H_p + V_p;
%% ML estimate of CFR at pilot locations
Cv_inv = inv(C_v);
Xp_herm = X_p';
C = C_v; %1/(X_p'*(1/C_v)*X_p);
Hcap_ml_p = C*Xp_herm*Cv_inv*Y_p;
% Weiner smoother for Hmmse
R_hhml = xcorr2(HH,Hcap_ml_p');
R_hmlhml = xcorr2(H_p,H_p') + C;
W_opt = R_hhml*inv(R_hmlhml);
% actual CFR over the resource block : H
% requires the knowledge of channel PDP and fade characteristics
% therefore, we go uniform scattering function to design smothening filter
% vectorized optimal mmse estimate of CFR over RB
Hcap_mmse = W_opt*Hcap_ml_p;
%% Weiner smoother for using real uniform scattering function
% calculate r_rob
fdd = fd*ts; % normalized doppler freq
N = 1024;
r_rob1(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(0));
r_rob2(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(1));
r_rob3(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(2));
r_rob4(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(3));
r_rob5(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(4));
r_rob6(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(5));
%vectorized correlation
r_rob = [r_rob1 r_rob2 r_rob3 r_rob4 r_rob5 r_rob6]';
% uniform Weiner smoother
W_rob = [r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob];
%% ML estimate of CFR over the entire RB using uniform WF
Hcap_rob = W_rob*Hcap_ml_p;
%% create RB: 18 subcarriers x 6 OFDM symbols
rb = zeros(18,6,1);
%% cluster means
m11 = (Hcap_rob(1)+Hcap_rob(2)+Hcap_rob(55)+Hcap_rob(56));
m1 = 0.25*m11;
m22 = 0.25*(Hcap_rob(45)+Hcap_rob(46)+Hcap_rob(99)+Hcap_rob(100));
m2 = 0.25*m22;
m33 = 0.25*(Hcap_rob(35)+Hcap_rob(36)+Hcap_rob(89)+Hcap_rob(90));
m3 = 0.25*m33;
%% shrinkage targets
% 3 clusters -> 5 shrinkage targets
% shrinkage target 1
Hst_1 = (1/12)*(m11+m22+m33)*ones(12,1);
% shrinkage target 2
Hst_2 = [m11*ones(2,1) ; m33*ones(2,1); m22*ones(2,1); m11*ones(2,1); m33*ones(2,1); m22*ones(2,1)];
%% modified JS estimate of CFR for the pilots
[temp1 temp2] = eigs(C);
C_max_eig = temp2(1,1);
p_tild = trace(C)/C_max_eig;
% second term
h2 = 1 - (p_tild - 2)/((Hcap_ml_p-Hst_1)'*inv(C)*(Hcap_ml_p-Hst_1)) ;
if (h2 >0)
H_js = Hst_1 + h2* (Hcap_ml_p-Hst_1);
else
H_js = Hst_1;
end
%% final CFR over the entire RB
H_js_2d = W_rob*H_js;
%% Error
p1(k)= (sum(conj(HH - Hcap_mmse).*(HH - Hcap_mmse)));
e1(j) = p1(k)+e1(j);
p2(k)=(sum(conj(HH - Hcap_rob).*(HH - Hcap_rob)));
e2 (j)= p2(k)+e2(j);
p3(k)=(sum(conj(HH - H_js_2d).*(HH - H_js_2d))) ;
e3 (j)=p3(k)+e3(j);
j=j+1;
end
for SNR_db=20:5:30
SNR = 10^(SNR_db/10); % Absolute SNR
lcp = 32; % Lcp = 32
pdp = exp(-([0:lcp]/2)); % exponential PDP
P = 12; % number of pilots
%% normalization of the energy for the QPSK constelation
temp = 0:3; % possible symbols
temp = qammod(temp,4); % modulated symbols
temp = abs(temp).^2; % power of each point in the constellation
temp = mean(temp); % average energy of the constellation
mod_norm = 1/sqrt(temp); % normaliztion factor
%% Get the channel
% Convert variance values to linear scale
sigma= pdp;
% Find the sum of sigma and normalize
sm = sum(sigma);
sigma = sigma/sm;
% scale the gains
for i=1:lcp
a(i)=(sigma(i)/2)*randn(1)+1j*(sigma(i)/2)*rand(1);
end
H = (1/sqrt(N))*fft(a,1024)';
HH = H(1:108,1);
H_p = [HH(1,1) HH(2,1) HH(55,1) HH(56,1) HH(45,1) HH(46,1) HH(99,1) HH(100,1) HH(35,1) HH(36,1) HH(89,1) HH(90,1)]';
% plot(ss);
%n=10.*log10(s.^2);
%% input data generation
% symbol generation for QPSK modulation
X = randi(4,1024,1)-1; % generation of 12x1 matrix of data symbols
% QPSK modulation
X1 = mod_norm*qammod(X,4);
X2 =(1/sqrt(N))* fft(X1,1024);
XX2 = X2(1:108,1);
Xp = [XX2(1,1) XX2(2,1) XX2(55,1) XX2(56,1) XX2(45,1) XX2(46,1) XX2(99,1) XX2(100,1) XX2(35,1) XX2(36,1) XX2(89,1) XX2(90,1)];
X_p = diag(Xp);
% %% channel estimates from ML estimator
% Hcap_ml = zeros(5,2,1);
%% Gaussian noise covariance
sigma2 = 1/SNR;
C_v = sigma2*eye(P);
%% Y_p is known at the output
V_p =(sigma2/2).*randn(12,1)+1j*(sigma2/2)*rand(12,1);
Y_p = X_p*H_p + V_p;
%% ML estimate of CFR at pilot locations
Cv_inv = inv(C_v);
Xp_herm = X_p';
C = C_v; %1/(X_p'*(1/C_v)*X_p);
Hcap_ml_p = C*Xp_herm*Cv_inv*Y_p;
% Weiner smoother for Hmmse
R_hhml = xcorr2(HH,Hcap_ml_p');
R_hmlhml = xcorr2(H_p,H_p') + C;
W_opt = R_hhml*inv(R_hmlhml);
% actual CFR over the resource block : H
% requires the knowledge of channel PDP and fade characteristics
% therefore, we go uniform scattering function to design smothening filter
% vectorized optimal mmse estimate of CFR over RB
Hcap_mmse = W_opt*Hcap_ml_p;
%% Weiner smoother for using real uniform scattering function
% calculate r_rob
fdd = fd*ts; % normalized doppler freq
N = 1024;
r_rob1(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(0));
r_rob2(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(1));
r_rob3(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(2));
r_rob4(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(3));
r_rob5(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(4));
r_rob6(1:18) = sinc(2*pi*lcp*(0:17)/N)*sinc(2*pi*fdd*(5));
%vectorized correlation
r_rob = [r_rob1 r_rob2 r_rob3 r_rob4 r_rob5 r_rob6]';
% uniform Weiner smoother
W_rob = [r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob r_rob];
%% ML estimate of CFR over the entire RB using uniform WF
Hcap_rob = W_rob*Hcap_ml_p;
%% create RB: 18 subcarriers x 6 OFDM symbols
rb = zeros(18,6,1);
%% cluster means
m11 = (Hcap_rob(1)+Hcap_rob(2)+Hcap_rob(55)+Hcap_rob(56));
m1 = 0.25*m11;
m22 = 0.25*(Hcap_rob(45)+Hcap_rob(46)+Hcap_rob(99)+Hcap_rob(100));
m2 = 0.25*m22;
m33 = 0.25*(Hcap_rob(35)+Hcap_rob(36)+Hcap_rob(89)+Hcap_rob(90));
m3 = 0.25*m33;
%% shrinkage targets
% 3 clusters -> 5 shrinkage targets
% shrinkage target 1
Hst_1 = (1/12)*(m11+m22+m33)*ones(12,1);
% shrinkage target 2
Hst_2 = [m11*ones(2,1) ; m33*ones(2,1); m22*ones(2,1); m11*ones(2,1); m33*ones(2,1); m22*ones(2,1)];
%% modified JS estimate of CFR for the pilots
[temp1 temp2] = eigs(C);
C_max_eig = temp2(1,1);
p_tild = trace(C)/C_max_eig;
% second term
h2 = 1 - (p_tild - 2)/((Hcap_ml_p-Hst_1)'*inv(C)*(Hcap_ml_p-Hst_1)) ;
if (h2 >0)
H_js = Hst_1 + h2* (Hcap_ml_p-Hst_1);
else
H_js = Hst_1;
end
%% final CFR over the entire RB
H_js_2d = W_rob*H_js;
%% Error
p1(k)= (sum(conj(HH - Hcap_mmse).*(HH - Hcap_mmse)));
e1(j) = p1(k)+e1(j);
p2(k)=(sum(conj(HH - Hcap_rob).*(HH - Hcap_rob)));
e2 (j)= p2(k)+e2(j);
p3(k)=(sum(conj(HH - H_js_2d).*(HH - H_js_2d))) ;
e3 (j)=p3(k)+e3(j);
j=j+1;
end
end
e1=10*log(e1/100);
e2=10*log(e2/100);
e3=10*log(e3/100);
j=-5:5:30;
plot(j,e1,'b')
hold on
plot(j,e2,'g')
hold on
plot(j,e3,'r')
title('MSE performance as a function of SNR')
xlabel('SNR in dB');
ylabel('MSE in dB');
legend('optimal MMSE','2d-MMSE with uniform scattering','JS-2d-MMSE');