Escolar Documentos
Profissional Documentos
Cultura Documentos
---------- Post added at 05:23 AM ---------- Previous post was at 05:22 AM ----------
N=length(channel_output);
SNRdB= -10:5:20;
SNR=10.^(SNRdB/10);
Counter=zeros(1,length(SNRdB));
loop=0;
%************************************************* **************
% AWGN + fading *
%************************************************* **************
Fd=66; % Actual fading rate
fm=round(Fd*NA*Ts);
%Sum the square the of the IFFT and take the square root of it
rx=sqrt(xifft.^2+yifft.^2);
%************************************************* ***************
%Calculate for all value of SNRdB in AWGN + fading
%************************************************* ***************
loop=0;
for b=sqrt(SNR) %b is the signal level
loop=loop+1;
dfad=0;
for n=1NA+2)*3 %n = no of bits
x=randn;
t=channel_output(n);
if t>=0.5
a=b*rx(n);
r=a+x;
if r<0
dfad=dfad+1; % error has occured, increase counter
Df(n)=0;
else
Df(n)=1;
end
else
a=(-b)*rx(n);
r=a+x;
if r>0
dfad=dfad+1;
Df(n)=1;
else
Df(n)=0;
end
end
Counterf(loop)=dfad; % w/o decode
end
output=viterbi(G,k,Df); % E is output of decoder
zf=0;
v=1;
for v=v:1:length(A);
if xor(input(1,v),output(1,v))==1
zf=zf+1;
end
end
Counter_wcf(loop)=zf;
end% loop for signal (b) in AWGN + fading
---------- Post added at 05:25 AM ---------- Previous post was at 05:23 AM ----------
clear;
Ts=1/1e3; % tx rate = 10k bps
NA=10000;
A=floor(rand(1,NA)+0.5);
%A=randint(1,NA);
input=A;
G=[1 0 0; 1 0 1; 1 1 1];
k=1;
N=length(channel_output);
SNRdB= -10:5:20;
SNR=10.^(SNRdB/10);
Counter=zeros(1,length(SNRdB));
loop=0;