www.pudn.com > ls_mmse_lmmse.rar > SSER_compare.m, change:2008-05-29,size:5112b

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);% 频域 XFG=X*H; n1=ones(64,1); n1=n1*0.000000000000000001i;%加入复高斯白噪声 noise=awgn(n1,8);%设置SNR为8db variance=var(noise); N=fft(noise); Y=XFG+N; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 求出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 n=1:6 SNR_send=3*n; error_count_ls=0;%清空error_count.. error_count_mmse=0;%清空the error_count.. error_count_smmse=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %求H_ls %H_ls=inv(X)*Y; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% H_ls=(inv(X)) * Y; Hls=zeros(64,64); for i=1:64 Hls(i,i)=H_ls(i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %求Hmmse %H_mmse=F*Rgg*inv(Rgy)*Y; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% u=rand(64,64); F=fft(u)*inv(u);%DFT矩阵 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% u=rand(64,64); F=fft(u)*inv(u);%DFT矩阵 I=eye(64,64); Rhh=F*Rgg*F'; H_smmse=Rhh*inv(Rhh+(1/SNR_send)*I)*H_ls; for i=1:64 Hsmmse(i,i)=H_smmse(i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for c=1:1000 %生成随机序列 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; n1=ones(64,1); n1=n1*0.000000000000000001i;%加入复高斯白噪声 noise=awgn(n1,SNR_send); variance=var(noise); N=fft(noise); Y=XFG+N; %接收机 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % I:LS估计器的接收： %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I=inv(Hls)* Y; for k=1:64 if(real(I(k))>0)%判决 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估计器的接收： %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I=inv(Hmmse)* Y; for k=1:64 if(real(I(k))>0)%判决 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % I:SMMSE估计器的接收： %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I=inv(Hsmmse)* Y; for k=1:64 if(real(I(k))>0)%判决 I(k)=1; else I(k)=-1; end end for k=1:64 if(I(k)~=d(k)) error_count_smmse=error_count_smmse+1; end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end ser_ls(n)=error_count_ls/64000; ser_mmse(n)=error_count_mmse/64000; ser_smmse(n)=error_count_smmse/64000; ser_ls ser_mmse ser_smmse SNR(n)=SNR_send; end; %作图 semilogy(SNR,ser_mmse,'-vk'); axis([2,18,0.01,1]); grid on; xlabel('SNR in DB'); ylabel('Symbol Error Rate'); title('OFDM系统MMSE,LS和SMMSE算法的比较（SER）'); hold on; semilogy(SNR,ser_ls,'-*b'); axis([2,18,0.01,1]); grid on; xlabel('SNR in DB'); ylabel('Symbol Error Rate'); title('OFDM系统MMSE,LS和SMMSE算法的比较（SER）'); hold on; semilogy(SNR,ser_smmse,'-or'); axis([2,18,0.01,1]); grid on; xlabel('SNR in DB'); ylabel('Symbol Error Rate'); title('OFDM系统MMSE,LS和SMMSE算法的比较（SER）'); legend('MMSE算法','LS算法','SMMSE算法'); hold off