?? test2.m
字號(hào):
for m =1:10
%Transmitter side
% we first generate the 20ms frame of 192 bits
info=Data(192);
% we convolutionally encoder the user data
conv=Conv_Encoder(info);
% we interleave our convolutional encoded user data
int_matrix=Interleaver(conv);
% we generate our Long PN sequence
% starting state of the Long PN sequence generator stage register
% starting state with 41 0s and a 1
starting=zeros([1,41]);
starting=[starting 1];
T_PN_out=T_Long_PN(starting);
% we decimate the Long PN chips
T_decit=T_Decimator(T_PN_out);
% we scramble the intereleaved user data with the decimated PN chips
T_scrambled=T_Scrambler(T_decit,int_matrix);
% we walsh code our scrambed data symbols
% assume we use channel 23
chan=23;
walshed=Walsh_cod(T_scrambled,chan);
% we perform IQ modulation to our walsh coded data chips
% I and Q pilot PN sequence generator shift register starting states with 14 0s and a 1
Istarting=zeros([1,14]);
Istarting=[Istarting 1];
Qstarting=zeros([1,14]);
Qstarting=[Istarting 1];
T_oWave=IQ_mod(walshed,Istarting,Qstarting);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
% The channel
%NL='SET THE SNR';
NL=0;
%multipaths=Channel(T_oWave,NL,'SET THE NUMBER OF INTERFEERING SIGNALS');
multipaths=Channel(T_oWave,NL,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
% Receiver side
% we perform maximal combining of the correlators output
combined=Maximal_comb(multipaths,3);
% we perform IQ demodulation to the received signal
R_received=IQ_demod(combined,Istarting,Qstarting);
% we Walsh decode our received signal
dewalshed=Walsh_dec(R_received,chan);
% we generate our Long PN sequence
R_PN_out=R_Long_PN(starting);
% we decimate the Long PN chips
R_decit=R_Decimator(R_PN_out);
% we descrambled the decimated Long PN chips with the Walsh decoded data symbols
R_scrambled=R_Scrambler(R_decit,dewalshed);
% we deinterleave our descrambled data symbols
deint_matrix=Deinterleaver(R_scrambled);
% we perform viterbi decoding
sysout=Viterbi_Decoder(deint_matrix);
for i=1:12288
if real(combined(i))>=0
combined(i)= combined(i)- real(combined(i))+1;
end
if real(combined(i))<0
combined(i)=combined(i)-real(combined(i))-1;
end
if imag(combined(i))>=0
combined(i)=real(combined(i))+(1*sqrt(-1));
end
if imag(combined(i))<0
combined(i)=real(combined(i))+(-1*sqrt(-1));
end
end
check ='THE Hamming distance between T_oWave and combined equals'
check1=length(find(T_oWave- combined))
check1T=[check1T check1];
check2='THE Hamming distance between walshed and R_received equals'
check2=length(find(walshed- R_received))
check2T=[check2T check2];
check3='THE Hamming distance between T_scrambled and dewalshed equals'
check3=length(find(T_scrambled- dewalshed))
check3T=[check3T check3];
check4='THE Hamming distance between int_matrix and R_scrambled equals'
check4=length(find(int_matrix- R_scrambled))
check4T=[check4T check4];
check5='THE Hamming distance between info and susout equals,hence BER of system equals'
check5=length(find(info- sysout))
check5T=[check5T check5];
end
check1T=[check1T sum(check1T(1:10))/10]
check2T=[check2T sum(check2T(1:10))/10]
check3T=[check3T sum(check3T(1:10))/10]
check4T=[check4T sum(check4T(1:10))/10]
check5T=[check5T sum(check5T(1:10))/10]
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -