• huosheng
    了解作者
  • matlab
    开发工具
  • 4KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 32
    下载次数
  • 2019-06-04 11:19
    上传日期
LS 、MMES信道估计MES对比,MATLAB下直接可以运行
信道估计.rar
  • 信道估计
  • MMSE_CE.m
    1007B
  • main.m
    7.1KB
  • LS_CE.m
    642B
  • interpolate.m
    712B
内容介绍
clc; clear all; close all; Nfft=2048; Ng=512; % Ng=Nfft/4 Nofdm=2560; % 一个ofdm符号的比特数,Nofdm=Nfft+Ng,Ng是cp的长度 Nsym=100;%符号序列长度 Nps=4; % Pilot Spacing导频间隔 Np=Nfft/Nps; %Number of pilots per OFDM symbol每个OFDM符号的导频数 Nbps=4; itr=10; nn=11; %No. of SNR observations %Initialising MSE arrays for different SNR observations:(初始化均方误差矩阵,初始值都是零) z_linin=zeros(1,nn); z_splin=zeros(1,nn); z_lindft=zeros(1,nn); z_spldft=zeros(1,nn); zmmse=zeros(1,nn); zmmse_dft=zeros(1,nn); for t=1:itr z=[]; z1=[]; z2=[]; z3=[]; zm=[]; zms=[]; snr1=[]; % 16 - QAM - Modulation Scheme M=16; hmod = modem.qammod('M',M, 'SymbolOrder','gray'); Es=1; A=sqrt(3/2/(M-1)*Es); % Signal energy and QAM normalization factor!! for nsym=1:Nsym Xp = 2*(randn(1,Np)>0)-1; % Pilot sequence generation:先把随机序列变成0,1序列,再把0,1序列变成双极性 msgint=randi(1,Nfft-Np,M); % bit generation (1行*(Nfft-Np)列随机整数,每个随机整数属于[0,M-1]) dat_ser = A*modulate(hmod,msgint); %只针对实数进行调制 end % serial to parllel conversion (串行到并行的转换)!! dat_par=dat_ser.'; % Pilot Insertion - Comb Type Arrangement(导频插入-梳状排列) counter = 0; loc = []; for i=1:Nfft if mod(i,Nps)==1 X(i)=Xp(floor(i/Nps)+1); %把导频放到相应的子载波上 loc=[loc i]; counter = counter+1; else X(i) = dat_par(i-counter);%把导频之外的信息比特放到其他子载波上 end end % inverse discret Fourier transform (IFFT) X_ifft=ifft(X,Nfft); % Adding Cyclic Prefix - Guard interval加循环前缀 guard=X_ifft(:,end-511:end); % this is the Cyclic Prefix part to be appended.!循环前缀 ofdm_par=[guard X_ifft]; % parallel to serial - Generation of the OFDM Signal ofdm=ofdm_par.';%输入符号x %%%%%%%%%%%%%%%%%%%%%%%%%%% 构建信道 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Channel code dopjakes = doppler.jakes; %(多普勒频谱对象,用作信道channel的属性)多普勒谱的一种,jakes模型 dopgauss1 = doppler.bigaussian;%另一种多普勒谱类型 双高斯模型 %其中的参数设置 dopgauss1.CenterFreqGaussian1 = -0.8;%归一化中心频率 dopgauss1.CenterFreqGaussian2 = 0.4; dopgauss1.SigmaGaussian1 = 0.05;%归一化标准差 dopgauss1.SigmaGaussian2 = 0.1; dopgauss1.GainGaussian1 = sqrt(2*pi*(dopgauss1.SigmaGaussian1)^2);%功率增益 dopgauss1.GainGaussian2 = 1/10 * sqrt(2*pi*(dopgauss1.SigmaGaussian2)^2); dopgauss2 = doppler.bigaussian; dopgauss2.CenterFreqGaussian1 = 0.7; dopgauss2.CenterFreqGaussian2 = -0.4; dopgauss2.SigmaGaussian1 = 0.1; dopgauss2.SigmaGaussian2 = 0.15; dopgauss2.GainGaussian1 = sqrt(2*pi*(dopgauss1.SigmaGaussian1)^2); dopgauss2.GainGaussian2 = 1/10^1.5 * sqrt(2*pi*(dopgauss1.SigmaGaussian2)^2); fd=130; %Maximum Doppler Shift ts=(7/64)*10^-6; %Sampling Time chan = rayleighchan(ts, fd); %Rayleigh channel - Multifading Channel % Assign profile-specific properties to channel object. chan.PathDelays = [0.0 0.2 0.5 1.6 2.3 5.0] * 1e-6; chan.AvgPathGaindB = [-3 0 -2 -6 -8 -10]; chan.DopplerSpectrum = [dopjakes dopjakes dopjakes dopgauss1 dopgauss2 dopgauss2];%设置对应于每条时延路径的多普勒谱 chan.StoreHistory = 1;%设置为1,可以把信道信息记录下来 chan.ResetBeforeFiltering = 0;%设置为0,表示信道增益的状态是连续的,表明信道没有发生质的变化 chan.NormalizePathGains = 1;%设置为1时,每条路径增益绝对值的平方和(功率和)的平均值为1 %Passing OFDM Signal through the created Channel chan_op = filter(chan,ofdm); XFG=fft(chan_op); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Channel Covariance(协方差矩阵) Matrix for MMSE estimation x_test=randn(1,6); % x_test=randn(1,45); X_test=fft(x_test,Nfft); y_test=filter(chan,x_test); Y_test=fft(y_test,Nfft); H1=Y_test/X_test; h=ifft(H1,6); % h=ifft(H1,45); H=fft(h,Nfft); ch_length=length(h);%%%%%%%%%%%%%!!!!!!为了求ch_length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Reception at the receiver end for various SNR ranging from 5dB - 25dB: for SNR =5:2:25 %AWGN Modelling snr1=[snr1 SNR]; n1=ones(2560,1); n1=n1*0.000000000000000001i;%Just to ensure that the function awgn adds 'complex gaussian noise'.. noise=awgn(n1,SNR); variance=var(noise);%求方差 N=fft(noise); Y_rec=XFG+N; y_ser=ifft(Y_rec); % serial to parallel conversion y_par=y_ser.'; % guard interval(去保护间隔) y = y_par(Ng+1:Nofdm); % FFT Y = fft(y); % channel estimation %LS Estimator with Linear Interpolator H_est = LS_CE(Y,Xp,loc,Nfft,Nps,'linear'); err=(H-H_est)*(H-H_est)'; z=[z err/(Nfft*Nsym)]; %LS Estimator with Linear Interpolator - DFT Based h_est = ifft(H_est); h_DFT = h_est(1:ch_length); H_DFT = fft(h_DFT,Nfft); err=(H-H_DFT)*(H-H_DFT)'; z3=[z3 err/(Nfft*Nsym)]; %LS Estimator with Spline Cubic Interpolator H_est = LS_CE(Y,Xp,loc,Nfft,Nps,'spline'); err=(H-H_est)*(H-H_est)'; z1=[z1 err/(Nfft*Nsym)]; %LS Estimator with Spline Cubic Interpolator - DFT Based h_est = ifft(H_est); h_DFT = h_est(1:ch_length); H_DFT = fft(h_DFT,Nfft); err=(H-H_DFT)*(H-H_DFT)'; z2=[z2 err/(Nfft*Nsym)]; % MMSE Estimator H_est = MMSE_CE(Y,Xp,loc,Nfft,Nps,h,SNR); err=(H-H_est)*(H-H_est)'; zm=[zm err/(Nfft*Nsym)]; % MMSE Estimator - DFT Based h_est = ifft(H_est); h_DFT = h_est(1:ch_length); H_DFT = fft(h_DFT,Nfft); err=(H-H_DFT)*(H-H_DFT)'; zms=[zms err/(Nfft*Nsym)]; end z_linin=z_linin+z; z_splin=z_splin+z1; z_lindft=z_lindft+z2; z_spldft=z_spldft+z2; zmmse=zmmse+zm; zmmse_dft=zmmse_dft+zms; end figure(1) semilogy(snr1,(1/itr)*z_linin,'r+:', snr1,(1/itr)*z_splin,'bo:', snr1,(1/itr)*z_lindft,'--xg', snr1,(1/itr)*z_spldft,'--sc'); legend('LS - Linear Interpolation','LS - Spline Cubic Interpolation','LS - Linear Interpolation(DFT)','LS - Spline Cubic Interpolation(DFT)'); xlabel('SNR'); ylabel('MSE'); grid on hold on figure(2) semilogy(snr1,(1/itr)*zmmse,'r+:',snr1,(1/itr)*zmmse_dft,'bo:'); xlabel('SNR'); ylabel('MSE'); legend('MMSE','MMSE - DFT Based'); hold on grid on figure(3) semilogy(snr1,(1/itr)*z_linin,'r+:', snr1,(1/itr)*z_splin,'bo:', snr1, (1/itr)*zmmse,'--xg'); xlabel('SNR'); ylabel('MSE'); legend('LS - Linear Interpolation','LS - Spline Cubic Interpolation','MMSE'); hold on grid on
评论
    相关推荐