?? walsh_dec.m
字號:
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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -