本人表示,确实不怎么会。有什么简单一点求自相关矩阵的方法吗以下是代码,是用训练序列做的,不知道答辩的时候老师会怎么说
真心跪求了
clear all;
%Generation of a naive training sequence.. 一个本地训练序列的生成
%Assuming BPSK modulation ...symbols:+1/-1 假设BPSK调制……符号:+ 1 / 1
X=zeros(64,64);
d=rand(64,1);
for i=1:64
if(d(i)>=0.5)
d(i)=+1;
else
d(i)=-1;
end
end
for i=1:64
X(i,i)=d(i);
end
%Calculation of G[The channel Matrix] 计算信道矩阵G
%The channnel is...
tau=[0.5 3.5];%The fractionally spaced taps.. 分数间隔抽头..
%Generation of the G matrix... G矩阵的生成
for k=1:64
s=0;
for m=1:2
s=s+(exp(-j*pi*(1/64)*(k+63*tau(m))) * (( sin(pi*tau(m)) / sin(pi*(1/64)*(tau(m)-k)))));
%Go through the above cited paper for the theory behind the formula 为后面的公式的理
end
g(k)=s/sqrt(64);
end
G=g';%Thus, the channel vector is evaluated.. 信道向量估计
H=fft(G);% In the freq domain.. 在频率域中
XFG=X*H;
n1=ones(64,1);
n1=n1*0.000000000000000001i;%Just to ensure that the function awgn adds 'complex gaussian noise'..
%%只是为了确保该函数的AWGN加复杂的高斯噪声’。
noise=awgn(n1,8);%Assuming the 'channel learning' is happening at 8db..假设信道估计是发生在8dB ..
variance=var(noise);
N=fft(noise);
Y=XFG+N;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Evaluation of the autocovariance matrix of G-Rgg %的g-rgg自协方差矩阵评估
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gg=zeros(64,64);
for i=1:64
gg(i,i)=G(i);
end
gg_myu = sum(gg, 1)/64;
gg_mid = gg - gg_myu(ones(64,1),
;
sum_gg_mid= sum(gg_mid, 1);
Rgg = (gg_mid' * gg_mid- (sum_gg_mid' * sum_gg_mid) / 64) / (64 - 1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%OK..Now that we have the ingredients ready,lets move on and evaluate the estimated channels by the
%use of the LS and the MMSE algorithms..
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EVALUATION OF Hls
%Hmmse=inv(X)*Y;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
H_ls=(inv(X)) * Y;
Hls=zeros(64,64);
for i=1:64
Hls(i,i)=H_ls(i);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EVALUATION OF Hmmse
%Hmmse=F*Rgg*inv(Rgy)*Y;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u=rand(64,64);
F=fft(u)*inv(u);%The 64 X 64 twiddle factor matrix..
I=eye(64,64);
Rgy=Rgg * F'* X';
Ryy=X * F * Rgg * F' *X' + variance * I;
for i=1:64
yy(i,i)=Y(i);
end
Gmmse=Rgy * inv(Ryy)* Y;
H_mmse=fft(Gmmse);
for i=1:64
Hmmse(i,i)=H_mmse(i);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Fine..the channels have been estimated , now is the time for real time simulations..
for n=1:6
SNR_send=5*n;
error_count_ls=0;%Clear the error_count..
error_count_mmse=0;%Clear the error_count..
%Sending around 1000 data vectors through the channel
%Roughly like 1000 simulations per SNR reading..
for c=1:1000
%Generate Random Data[i/p matrix..]
X=zeros(64,64);
d=rand(64,1);
for i=1:64
if(d(i)>=0.5)
d(i)=+1;
else
d(i)=-1;
end
end
for i=1:64
X(i,i)=d(i);
end
XFG=X*H;%Let it go through the actual channel...
n1=ones(64,1);
n1=n1*0.000000000000000001i;%Just to ensure that the function awgn adds 'complex gaussian noise'..
noise=awgn(n1,SNR_send);
variance=var(noise);
N=fft(noise);
Y=XFG+N;%o/p got by the receiver...
%The receiver begins....
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% I:LS ESTIMATOR BASED RECEIVER:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%I(k) represents the decision matrix..
I=inv(Hls)* Y;
for k=1:64
if(real(I(k))>0)%Putting it through a slicer
I(k)=1;
else
I(k)=-1;
end
end
for k=1:64
if(I(k)~=d(k))
error_count_ls=error_count_ls+1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% I:MMSE ESTIMATOR BASED RECEIVER:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%I(k) represents the decision matrix..
I=inv(Hmmse)* Y;
for k=1:64
if(real(I(k))>0)%Putting it through a slicer
I(k)=1;
else
I(k)=-1;
end
end
for k=1:64
if(I(k)~=d(k))
error_count_mmse=error_count_mmse+1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end%End of the 1000 run simulation..
ser_ls(n)=error_count_ls/64000;
ser_mmse(n)=error_count_mmse/64000;
ser_ls
ser_mmse
SNR(n)=SNR_send;
end;
%Now just the display part.....
semilogy(SNR,ser_mmse,'k-');
grid on;
xlabel('SNR');
ylabel('BER');
title('LTE系统的LS和MMSE信道估计');
hold on;
semilogy(SNR,ser_ls,'b*');
semilogy(SNR,ser_ls,'b-');
semilogy(SNR,ser_mmse,'kv');
grid on;
xlabel('SNR in DB');
ylabel('Symbol Error Rate');
title('LTE系统的LS和MMSE信道估计');
legend('LS算法','MMSE算法');
hold off