Digital Communication Lab Cycle-2 Name: Charitha T S SRN: PES2201800220 Class: ECE-6A
Digital Communication Lab Cycle-2 Name: Charitha T S SRN: PES2201800220 Class: ECE-6A
Digital Communication Lab Cycle-2 Name: Charitha T S SRN: PES2201800220 Class: ECE-6A
SRN : PES2201800220
2
Theory :
with and ,
SRN : PES2201800220
3
Code :
clc;
clear all;
close all;
n = 10^7;
s = 2*(rand(1,n)>0.5)-1;
EbNo = [-4:2:10];
for i = 1:length(EbNo)
no = 10^(-EbNo(i)/10);
nvar = no/2;
w = randn(1,n)*sqrt(nvar);
x = s+w;
s_hat = 2*(x>0)-1;
nerr = sum((abs(s-s_hat))/2);
ber(i) = nerr/n;
pe(i) = (0.5)*erfc(sqrt(1/no));
end
semilogy(EbNo,ber,'-dk'); %simulated BER
hold on;
semilogy(EbNo,pe,'-m'); % theoritical BER
title('BER plot for BPSK');
xlabel('E_b / N_0 in dB');
ylabel('Probability of error');
no=10^(-2/10);
nvar=no/2;
w=randn(1,n)*sqrt(nvar);
x=s+w;
scatterplot(x); % for E_b / N_0 = 2 dB
title('Scatterplot');
xlabel('In-Phase');
ylabel('Quadrature');
xlim([-4 4])
ylim([-4 4])
SRN : PES2201800220
4
SRN : PES2201800220
5
Theory :
From the symbol error rate vs Eb/No plot, we know that for the same
value of SNR per bit (Eb/No), the symbol error rate for QPSK is double
that of BPSK; and the symbol error rate of 16QAM is double that of
4PAM. So, I think that the points should not overlap (should be offset by
around 0.3dB).
SRN : PES2201800220
6
with and
Code :
clc;
clear all;
close all;
n = 10^7;
s = (2*(rand(1,n)>0.5)-1)+1j*(2*(rand(1,n)>0.5)-1);
EbNo = [-4:2:12];
for i = 1:length(EbNo)
no = 10^(-EbNo(i)/10);
nvar = no/2;
w = (randn(1,n)+1j*randn(1,n))*sqrt(nvar);
x = s+w;
xr=real(x);
xi=imag(x);
s_hat = (2*(xr>0)-1)+1j*(2*(xi>0)-1);
nerr = size(find([s-s_hat]),2);
ser(i) = nerr/n;
pe(i) = erfc(sqrt(1/no));
end
SRN : PES2201800220
7
no=10^(-12/10);
nvar=no/2;
w =(randn(1,n)+1j*(randn(1,n)))*sqrt(nvar);
x=s+w;
scatterplot(x); % for E_b / N_0 = 2 dB
title('Scatterplot');
xlabel('In-Phase');
ylabel('Quadrature');
xlim([-2 2])
ylim([-2 2])
SRN : PES2201800220
8
Theory :
SRN : PES2201800220
9
The bit error probability for coherent binary frequency shift keying is
Code :
clc;
clear all;
close all;
n=10^7;
ebn=[0:2:14];
s=double(rand(1,n)>0.5);
st=s;
si=find(s==0);
st(si)=1*j;
for i=1:length(ebn)
no=10^(-ebn(i)/10);
nvar=no/2;
w=(randn(1,n)+(j*randn(1,n)))*sqrt(nvar);
x=st+w;
xr=real(x);
xi=imag(x);
sh=double(xr>xi);
nerr=size(find(s-sh),2);
ber(i)=nerr/n;
pe(i)=0.5*erfc(sqrt(1/(2*no)));
end
semilogy(ebn,ber,'-sb');
hold on
semilogy(ebn,pe,'-*r');
title('BER OF BFSK');
xlabel('EbNo in dB');
ylabel('BER');
legend('Practical BER','Theoretical BER');
SRN : PES2201800220
10
SRN : PES2201800220
11
Theory :
The phase shift θ is the same during two consecutive signal transmission
intervals [(n-1)T, nT) and [nT, (n+1)T). The information phase sequence
{∆θ n} is still differentially encoded as before. The received waveform is
then r(t)=s(t)+n(t) . To derive the optimal receiver, the observation
interval should be taken as (n-1)T ≤ t
Pb=Pe=1/2e-Eb/N0
SRN : PES2201800220
12
Code :
clc;
clear all;
close all;
n=10^7;
s=rand(1,n)>0.5;
d=zeros(1,n+1);
d(1)=1;
for i=1:n
d(i+1)=not(xor(d(i),s(i)));
end
d=d(1,2:end);
d=2*d-1;
ebn=[-4:2:10];
for j=1:length(ebn)
no=10^((-ebn(j))/10);
nvar=no/2;
w=randn(1,n)*sqrt(nvar);
x=d+w;
xd=[1 x(1:end-1)];
sh=(x.*xd)>0;
ner=sum(abs(s-sh));
ber(j)=ner/n;
pe(j)=0.5*exp(-1/no);
end
semilogy(ebn,ber,'-dk');
hold on;
semilogy(ebn,pe,'-*m');
xlabel('Eb by No in dB');
ylabel('BER');
title('Bit error rate of DPSK');
legend('Simulated BER','Theoretical BER');
SRN : PES2201800220
13
SRN : PES2201800220