OH. sorry!
noc=128
Thanks,again!
>hey mib,
> one thing i didnt understand
>
>is M = (128*6*2)/1024 = (12)/(8) = (3)/(2)
>
>if so,
>is this right in matlab ??
>
>gamma = zeros(3/2,1024); % what does this generate
>lamda = zeros(3/2,1024); % what does this generate
>
> gamma =zeros(M,noc);
>lamda =zeros(M,noc);
>
>where 128 = para;
> 6 = ml;
> 2 = nd;
> noc = 1024;
>
>
>mib wrote:
>> Hi All!
>> I have written a section of codes according to the J.J. van de Beek's
<ML
>> Estimation of time and frequence offset in OFDM system>, but the result
is
>> wrong. I do not know why, I hope someone can help me,thanks!
>>
>> clear all;
>>
>> %********************** preparation part ***************************
>>
>> para=128; % Number of parallel channel to transmit (points)
>> fftlen=128; % FFT length
>> noc=1024; % Number of carrier
>> nd=6; % Number of information OFDM symbol for one loop
>> ml=2; % Modulation level : QPSK
>> sr=250000; % Symbol rate
>> br=sr.*ml; % Bit rate per carrier
>> gilen=128; % Length of guard interval (points)
>> ebn0=3; % Eb/N0
>> SNR=15; % ENR
>>
>> %************************** transmitter
*********************************
>>
>> %************************** Data generation
****************************
>>
>> seldata=rand(1,para*nd*ml)>0.5; % rand : built in function
>> M=length(seldata)/noc;
>> %****************** Serial to parallel conversion
***********************
>>
>> paradata=reshape(seldata,para,nd*ml); % reshape : built in function
>>
>> %************************** QPSK modulation
*****************************
>>
>>
>> [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);
>>
>> %***************** AWGN addition *********
>>
>> 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;
>>
>>
>>
>> %sampling_rx=[zeros(1,1) rx zeros(1,2*noc+gilen-1)];
>> for n=1:M
>> for theta=1:noc
>>
>> % sampling_rx(n,:)=[rx(n,1:theta) real(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
>>
>>
>> figure(8);
>> %subplot(4,1,1);
>> plot(abs(gamma(1,:)))
>> %subplot(4,1,2);
>> %plot(pii(1,:))
>> %subplot(4,1,3);
>> %plot(abs(lamda));
>> %subplot(4,1,4);
>> %plot(real(sampling_rx(1,:)))
>>
>> figure(9);
>> plot(lamda(1,:))
>
>