www.pudn.com > ml.rar > mlmethod.m, change:2009-05-23,size:3063b


%%%%最大似然ML  最大似然方法联合实现符号定时同步和载波同步仿真 
clear all; 
%********************** preparation part *************************** 
para=128;   % Number of parallel channel to transmit (points) %并行信道传输个数 
fftlen=128; % FFT length %fft 长度 
noc=1024;    % Number of carrier %载波的个数 
nd=6;       % Number of information OFDM symbol for one loop%OFDM 符号个数 
ml=2;       % Modulation level : QPSK %调制方式:QPSK 
sr=250000;  % Symbol rate  %符号的比特率 
br=sr.*ml;  % Bit rate per carrier %每个载波的比特率? 
gilen=128;   % Length of guard interval (points)%%保护间隔的长度 
ebn0=3;     % Eb/N0  %Eb为单位比特的平均信号的能量;n0为噪声的单边功率普密度 
SNR=15;     % ENR  %信噪比 
T=10^(-6);   % Sampling time : 1us%%采样时间1us 抽样频率1024kHz 
%************************** transmitter发射机 ********************************* 
%************************** Data generation 数据生成程序****************************  
seldata=rand(1,para*nd*ml)>0.5;  %  rand : built in function  %产生1x(128*6*2)=1X1536的数据 
M=length(seldata)/noc; 
%****************** Serial to parallel conversion串并转换 *********************** 
paradata=reshape(seldata,para,nd*ml); %  reshape : built in function 
%************************** QPSK modulation %QPSK 调制*****************************  
[ich,qch]=qpskmod(paradata,para,nd,ml); 
kmod=1/sqrt(2); %  sqrt : built in function 
ich1=ich.*kmod;%实部的数据 
qch1=qch.*kmod;%虚部的数据 
%******************* IFFT ************************ 
x=ich1+qch1.*i; 
y=ifft(x);      %  ifft : built in function 
ich2=real(y);   %  real : built in function 
qch2=imag(y);   %  imag : built in function 
%********* cyclic perfix insertion 循环保护间隔********** 
[ich3,qch3]= giins(ich2,qch2,fftlen,gilen,nd); 
fftlen2=fftlen+gilen; 
 
%***************** AWGN addition 叠加在 AWGN信道上*********  
ich4=AWGN(ich3,SNR); 
qch4=AWGN(qch3,SNR); 
rx=ich4+qch4.*i;%叠加噪声之后的数据 
%****************** Calculate gamma(m) & PI(m) ******************* 
gamma =zeros(M,noc); 
lamda =zeros(M,noc); 
pii =zeros(M,noc); 
ro = SNR/(SNR+1); 
e=0.25; 
for n=1:M 
    for theta=1:noc 
       
         sampling_rx(n,:)=[rx(n,1:theta) rx(n,:) rx(n,1:noc-theta)];  
         %sampling_rx=[rx(n,1:theta) rx(n,:) rx(n,1:noc-theta)];    
         %sampling_rx(n,:)=[zeros(1,theta) rx(n,:) zeros(1,noc-theta)]; 
          
       for k=theta:theta+gilen-1 
                %equation 2-(6),2-(7)                 
                gamma(n,theta)= gamma(n,theta)+sampling_rx(n,k)*conj(sampling_rx(n,k+noc)); 
                pii(n,theta)=pii(n,theta)+abs(sampling_rx(n,k))^2 + abs(sampling_rx(k+noc))^2; 
       end 
        gamma(n,theta) 
       pii(n,theta)=0.5*pii(n,theta); 
         
        %equation 2-(5) 
        lamda(n,theta)=abs(gamma(n,theta))*cos(2*pi*e+angle(gamma(n,theta))) - ro*pii(n,theta); 
         
    end 
end 
t=T:T:noc*T; 
figure(8); 
subplot(4,1,1); 
plot(abs(gamma(1,:))) 
subplot(4,1,2); 
plot(pii(1,:)) 
subplot(4,1,3); 
plot(lamda(1,:)) 
subplot(4,1,4); 
plot(real(sampling_rx(1,:))) 
figure(9); 
plot(t,lamda(1,:))