⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generatevectorsforffb.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
%
% generates Vectors for FFB
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: generateVectorsForFFB.m.rca $
%  Tag $Name:  $
%  $Revision: 1.1 $
%  $Date: Fri Dec  1 14:00:29 2006 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%-- Matlab files used by this file
%mFastFeedback
%mGenBin
%--


function generateVectorsForFFB

addpath('./..')

%-- General Settings
generateTV=1;
DataRange = 64;
SNRgap= 4;


%-- Generate the 64 vectors
P0=exp(i*pi/4);
P1=exp(i*pi*3/4);
P2=exp(-i*pi*3/4);
P3=exp(-i*pi*1/4);
l0 = [ P0; P1; P2; P3; P0; P1; P2; P3];
l1 = [ P0; P3; P2; P1; P0; P3; P2; P1];
l2 = [ P0; P0; P1; P1; P2; P2; P3; P3];
l3 = [ P0; P0; P3; P3; P2; P2; P1; P1];
l4 = [ P0; P0; P0; P0; P0; P0; P0; P0];
l5 = [ P0; P2; P0; P2; P0; P2; P0; P2];
l6 = [ P0; P2; P0; P2; P2; P0; P2; P0];
l7 = [ P0; P2; P2; P0; P2; P0; P0; P2];
tileLUT =  [l0 l1 l2 l3 l4 l5 l6 l7 ];

[LUT_SORTED, LUT_SORTED_full, LUTposs, LUTposs2,LUT_NONSORTED] = LUT;
temp = num2str(LUT_NONSORTED(:,2)+ones(64,1)*1e6);
temp = temp(:,2:end);

vectors = zeros(48,64);
ref = zeros(1,64);
for k=1:64
    for tile=1:6
        l(tile)=str2num(temp(k,tile));
        tileLUT(:,l(tile)+1);
        vectors(8*(tile-1)+1 :  8*(tile)   ,k) = tileLUT(:,l(tile)+1);
    end
    ref(k) = LUT_NONSORTED(k,1);
end

%-- Norm vectors and apply range.
vectors_N1=vectors./max(max(real(vectors)));
vectors=DataRange*round(vectors_N1);



%-- Create a realistic vector serie if no TV generation
if generateTV
    Nvec = 64; step=1;
    x=[1:step:Nvec*step];
    myVectors = vectors;
    myRef = x;
else
    Nvec = 629; step=0.01;
    x=[0:step:Nvec*step];
    y=sin(x)*DataRange/2 + DataRange/2;
    noise = (rand(1,Nvec+1)-0.5)*SNRgap;
    vectorsIndex = round(y+noise);
    vectorsIndex = min(vectorsIndex,64);
    vectorsIndex = max(vectorsIndex,1);
    vectorsIndex = round(vectorsIndex);
    for k=1:Nvec
        indice = vectorsIndex(1,k);
        myVectors(:,k) = vectors(:,indice);
        myRef(k) = indice;
    end
end




%-- Create test vectors with AWGN
disp('Generating FastFeedBack test vectors with noise.')
[m n]=size(myVectors);
rand('state',0); %always same vectors
SNRrange=[Inf -5 ];


for SNR=SNRrange

    disp(['SNR: ' int2str(SNR) ])
    for k=1:n
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % AWGN channel
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        if SNR==Inf
            vectorsNoisy(:,k) = myVectors(:,k);
        else %noise on
            SigPwr=mean(myVectors(:,k).*conj(myVectors(:,k)));
            dBW=10*log10(SigPwr);
            vectorsNoisy(:,k) = double(int16(awgn(myVectors(:,k),SNR,dBW)));
            %Noise= vectorsNoisy(:,k)-myVectors(:,k);
            %mean(Noise.*conj(Noise));
            %InsertedSNR(k)=10*log10(SigPwr/mean(Noise.*conj(Noise)));
            %disp(['InsertedSNR: ' num2str(InsertedSNR) ]);
        end
        mOut(k) =  mFastFeedback(vectorsNoisy(:,k));
    end

    %-- TV generation if needed
    if generateTV
        switch SNR
            case {Inf,-5}
                SNRstr = ['SNR' int2str(SNR)];
                %all vectors at once
                mGenBin(vectorsNoisy,['./vector/' SNRstr '/in/IF2RX_00_00_00_00.lod'],'int16','1R1I')
                mGenBin(mOut-1,['./vector/' SNRstr '/mout/Out__00_00_00_00.lod'],'int8','R')
                mGenBin(myRef-1,['./vector/' SNRstr '/ref/IF1mRX_00_00_00_00.lod'],'int8','R')
                disp(['Test vectors for FastFeedBack generated (' SNRstr ').'])
            otherwise
                disp('No test vectors generated')
        end
    end

end

disp('generateVectorsForFFB finished')

rmpath('./..')





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -