walsh_dec.m

来自「The result is an IS-95CDMA forward link 」· M 代码 · 共 72 行

M
72
字号

function dewalshed=Walsh_dec(R_received,channelnum)

%This is the Walsh decoder
%initialise the walsh matrix

de_walsh=hadamard(64);

%in the hadamard matrix. A〃0〃 is represented as a 1, a〃1〃 is represented as a〃-1〃 we need to convert the walsh matrix into 〃0〃s and ¨1〃s form
%0=1  -1=1

for col=1:64

    for row=1:64

      if de_walsh(col,row)==1
          de_walsh(col,row)=0;

       else
         de_walsh(col,row)=1;
      end

    end

end

%initialise temp for holding the matched data chips stream
matched =[];


%the output from IQ demodulator has 24576 chips,and we decode 64 chips at a time


for k=1:64:24576
   temp1=[];
   temp1=R_received(k:k+63);

   %2 buffer for the normal (for symbol 0)and inverted version(for symbol 1) of the row of walsh chips of the Hadamard matrix

  tempp1=de_walsh(channelnum,:);
  tempp2=~(de_walsh(channelnum,:));

   %calculate errors when matching the 64 chips sequence with each of the buffer

  err1 =length(find(tempp1-temp1));
  err2 =length(find(tempp2-temp1));


    if err1<err2
      matched =[matched,0];
    end

    if err2<err1
     matched =[matched,1];
    end

    if err1==err2
      chance=randn;
      if chance<=0
         matched=[matched,0];
      end
      if chance>0
         matched=[matched,1];
      end
    end
end
    

dewalshed=matched;


⌨️ 快捷键说明

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