www.pudn.com > ls_mmse_lmmse.rar > SMSE_compare.m, change:2008-05-24,size:2325b


clc; 
clear all; 
%生成训练序列 
%用BPSK调制 
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 
%计算出信道向量G 
 %信道特性 
  tau=[0.5 3.5]; 
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))))); 
      end 
g(k)=s/sqrt(64); 
end 
G=g';%信道向量 
H=fft(G);% 频域 
u=rand(64,64); 
F=fft(u)*inv(u);% DFT矩阵 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% 求出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); 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%多次计算,求平均 
for m=1:12 
     
for n=1:6 
 
SNR_send=3*n; 
XFG=X*H; 
n1=ones(64,1); 
n1=n1*0.000000000000000001i;%加入复高斯白噪声 
noise=awgn(n1,SNR_send); 
variance=var(noise); 
N=fft(noise); 
Y=XFG+N; 
%得出LS的均方误差 
mean_squared_error_ls=LS_MSE_calc(X,H,Y); 
%得出MMSE的均方误差 
mean_squared_error_mmse=MMSE_MSE_calc(X,H,Y,Rgg,variance); 
%得出SMMSE的均方误差 
mean_squared_error_smmse=SMMSE_MSE_calc(X,H,Y,Rgg,SNR_send); 
SNR(n)=SNR_send; 
mmse_mse(m,n)=mean_squared_error_mmse; 
ls_mse(m,n)=mean_squared_error_ls; 
smmse_mse(m,n)=mean_squared_error_smmse; 
end; 
 
end; 
ls_mse 
mmse_mse 
smmse_mse 
mmse_mse_ave=mean(mmse_mse); 
ls_mse_ave=mean(ls_mse); 
smmse_mse_ave=mean(smmse_mse); 
%作图 
semilogy(SNR,mmse_mse_ave,'-vk'); 
grid on; 
xlabel('SNR in DB'); 
ylabel('mean squared error'); 
title('OFDM系统MMSE,LS和SMMSE算法的比较(MSE)'); 
hold on; 
semilogy(SNR,ls_mse_ave,'-*b'); 
grid on; 
xlabel('SNR in DB'); 
ylabel('mean squared error'); 
title('OFDM系统MMSE,LS和SMMSE算法的比较(MSE)'); 
hold on; 
semilogy(SNR,smmse_mse_ave,'-or'); 
grid on; 
xlabel('SNR in DB'); 
ylabel('mean squared error'); 
title('OFDM系统MMSE,LS和SMMSE算法的比较(MSE)'); 
legend('MMSE算法','LS算法','SMMSE算法'); 
hold off