Demo entry 6735770

3

   

Submitted by anonymous on Apr 25, 2018 at 17:29
Language: Matlab. Code size: 5.4 kB.

load ('dataB.mat')
mc_RxCrudeData1 = chanOut1';
mc_RxCrudeData2 = chanOut2';
 
% cut the first 5000 data to perform synchronization
mc_SynchData1 = mc_RxCrudeData1(1:5000);
mc_SynchData2 = mc_RxCrudeData2(1:5000);
ddd=length(mc_SynchData1);
% get the reference parameters of preambles
[mc_PreambleFirstSymbol,mc_PreambleSecondSymbolEven,mc_PreambleSecondSymbolOdd, mc_PreambleAnt1, mc_PreambleFD] = sigPreambleOnTx;
mc_PreamblePrefix = mc_PreambleAnt1(1:64);  % the prefix of time domain signal of preamble, 64 samples
 
% get the frame head beginning position with sub function "syn"
n_FrameHeadPos1 = syn(mc_SynchData1,mc_PreamblePrefix);
n_FrameHeadPos2 = syn(mc_SynchData2,mc_PreamblePrefix);
 
%the programme will give the synchronization results thr the function "syn";
 
% Fractional Frequency Offset
r_FracFreqOffs1 = 0.5 * offsetFracFreq(mc_SynchData1, n_FrameHeadPos1);
r_FracFreqOffs2 = 0.5 * offsetFracFreq(mc_SynchData2, n_FrameHeadPos2);
 
% Integer Frequency Offset
r_InteFreqOffs1 = 0.5 * offsetInteFreq(mc_SynchData1, mc_PreambleFD, n_FrameHeadPos1); 
r_InteFreqOffs2 = 0.5 * offsetInteFreq(mc_SynchData2, mc_PreambleFD, n_FrameHeadPos2); 
 
% frequency correction
r_FreqCorr1 = (r_FracFreqOffs1 + r_InteFreqOffs1) * 31250;
r_FreqCorr2 = (r_FracFreqOffs2 + r_InteFreqOffs2) * 31250;
n_SampFreq = 8000000;
mc_RxDataSynCorr1 = mc_RxCrudeData1.*exp(j*2*pi*r_FreqCorr1*(1:length(mc_RxCrudeData1))/n_SampFreq);
mc_RxDataSynCorr2 = mc_RxCrudeData2.*exp(j*2*pi*r_FreqCorr2*(1:length(mc_RxCrudeData2))/n_SampFreq);
 
% Serial to parallel
% convert the rx data into m row n column matrix. n is the
% data length divided by 320, m is 320 (256 + 64 )
datalength = min(floor((length(mc_RxDataSynCorr1)-n_FrameHeadPos1)/320),floor((length(mc_RxDataSynCorr2)-n_FrameHeadPos2)/320));
for count1 = 1:datalength
      Mc_RxSynedTemp1(:,count1) = mc_RxDataSynCorr1(320*(count1-1)+n_FrameHeadPos1:320*count1+n_FrameHeadPos1-1).';
      Mc_RxSynedTemp2(:,count1) = mc_RxDataSynCorr2(320*(count1-1)+n_FrameHeadPos2:320*count1+n_FrameHeadPos2-1).';
end
 
 
% truncate the matrix to be the multiple of 6, 6 is the symbol number of one frame.
 
Mc_RxSyned1 = Mc_RxSynedTemp1(:,1:floor(length(Mc_RxSynedTemp1(1,:))/6)*6); 
Mc_RxSyned2 = Mc_RxSynedTemp2(:,1:floor(length(Mc_RxSynedTemp2(1,:))/6)*6); 
    
 
%removal of CP, CPRatio = 1/4.
Mc_RxSynedRmCP1 = Mc_RxSyned1((0.25*256)+1:320,: );
Mc_RxSynedRmCP2 = Mc_RxSyned2((0.25*256)+1:320,: );
 
%fft the receive signal
for countColumn=1:length(Mc_RxSynedRmCP1(1,:))
    Mc_RxFreqDomain1(:,countColumn) = fftshift(fft(Mc_RxSynedRmCP1(:,countColumn)));
end
 
for countColumn=1:length(Mc_RxSynedRmCP2(1,:))
    Mc_RxFreqDomain2(:,countColumn) = fftshift(fft(Mc_RxSynedRmCP2(:,countColumn)));
end
 
% LS Channel estimation
% Coeff1To1 means the channel coefficient from Tx 1 to Rx 1.
% Coeff2To1 means the channel coefficient from Tx 2 to Rx 1.
% Coeff1To2 means the channel coefficient from Tx 1 to Rx 2.
% Coeff2To2 means the channel coefficient from Tx 2 to Rx 2.
[Mc_CECoeff1To1Temp,Mc_CECoeff2To1Temp] = LSCEpreamble(Mc_RxFreqDomain1);
[Mc_CECoeff1To2Temp,Mc_CECoeff2To2Temp] = LSCEpreamble(Mc_RxFreqDomain2);
 
% repeat four times, the following four symbols use the preamble symbol CE % coefficient
for column = 1:length(Mc_CECoeff1To1Temp(1,:))*4
    Mc_CECoeff1To1(:,column) = Mc_CECoeff1To1Temp(:,1+floor((column-1)/4));
    Mc_CECoeff2To1(:,column) = Mc_CECoeff2To1Temp(:,1+floor((column-1)/4));
end
 
for column = 1:length(Mc_CECoeff1To2Temp(1,:))*4
    Mc_CECoeff1To2(:,column) = Mc_CECoeff1To2Temp(:,1+floor((column-1)/4));
    Mc_CECoeff2To2(:,column) = Mc_CECoeff2To2Temp(:,1+floor((column-1)/4));
end
 
% remove guard subcarriers
Mc_RxFreqDomainTemp1 = Mc_RxFreqDomain1(29:229,:);
Mc_RxFreqDomainTemp2 = Mc_RxFreqDomain2(29:229,:);
 
% remove preamble symbols
for count1 = 1: length(Mc_RxFreqDomain1(1,:))/6
    if count1 == 1
       Mc_RxDataFD1 = [Mc_RxFreqDomainTemp1(:,3:6)];
       count2 = 6;
   else
       Mc_RxDataFD1 = [Mc_RxDataFD1 Mc_RxFreqDomainTemp1(:,count2+3:count2+6)];
       count2 = count2 +6;
   end
end
 
for count1 = 1: length(Mc_RxFreqDomain2(1,:))/6
    if count1 == 1
       Mc_RxDataFD2 = [Mc_RxFreqDomainTemp2(:,3:6)];
       count2 = 6;
   else
       Mc_RxDataFD2 = [Mc_RxDataFD2 Mc_RxFreqDomainTemp2(:,count2+3:count2+6)];
       count2 = count2 +6;
   end
end
        
        
% LS equalizer
Mc_RxDemPhaseCorre = STBC_decoding_T2R2withPhaseCorre(Mc_RxDataFD1,Mc_RxDataFD2,Mc_CECoeff1To1,Mc_CECoeff2To1,Mc_CECoeff1To2,Mc_CECoeff2To2);
 
 
 
%remove DC term first and pilot subcarriers
Mc_RxDemed = [Mc_RxDemPhaseCorre(1:12,:);Mc_RxDemPhaseCorre(14:37,:);Mc_RxDemPhaseCorre(39:62,:);Mc_RxDemPhaseCorre(64:87,:);
              Mc_RxDemPhaseCorre(89:100,:);Mc_RxDemPhaseCorre(102:113,:);Mc_RxDemPhaseCorre(115:138,:);Mc_RxDemPhaseCorre(140:163,:); ...
              Mc_RxDemPhaseCorre(165:188,:);Mc_RxDemPhaseCorre(190:201,:)];
% Mc_RxDemed = Mc_RxDemPhaseCorre;
 
    
for CCC=1
    for count1=1:4
       figure(CCC+100);
       subplot(2,2,count1);
        plot(real(Mc_RxDemed(:,CCC*4-4+count1)), imag(Mc_RxDemed(:,CCC*4-4+count1)), '+');
        grid on;
        axis([-2 2 -2 2]);
        xlabel('Real');ylabel('Imaginary');
        title('Constellations after CE 2X2');
     end
end 
 
dem = Mc_RxDemed;
 
 
return

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).