1. Digital Communication Systems
Homework # 6
Muhammad Irfan Anjum
Matlab code is given in the Appendix.
BPSK Modulation ±1
Sampling frequency fs= 2000 Hz
Sampling interval T=1/fs
Symbol duration Ts=20/fs
Problem # 1
Matlab script to design root raised cosine filter p(kTs) with roll-off factor 0.5 and convolution of
two root raised cosine pulse is shown in fig. 1.
The graphs shown in Fig.1 are obtained using oversampling. It is clear from Fig.1 (b) that convolution of
two root raised cosine pulses is raise cosine pulse.
Problem # 2
Fig. 2 shows the time and frequency plots of transmitted BPSK symbols before and after passing
through pulse shaping filter shown in Fig.1.
Problem # 3
Fig. 3 shows the time and frequency plots of transmitted BPSK symbols before and after passing
through filter h(t), where h(t)=c(t)*p(t).
4. Fig. 3
Problem # 4
Fig. 4 shows the BER graphs of BPSK and 4-QAM modulations schemes in case of MLSD. It is
clear from the figure that BPSK performs better than 4-QAM in ISI channel.
5. Fig. 4
Appendix:
%% HomeWork#6, Digital Communication Systems...
clc
clear
close all
roll_off_factor=0.5; % Rolloff factor.
fs=2000; % Sampling rrequency.
Ts=1/fs; % Sampling rate.
T=20/fs; % Symbol duration
M=10^5; % Number of symbols
interval=-T/2:Ts:T/2;
SNR=0:3:15;
%% Problem #1
Index=1;
for t=interval
if t==0
p(Index)=1-roll_off_factor+4*roll_off_factor/pi;
elseif t== abs(Ts/(4*roll_off_factor))
6. p(Index)=roll_off_factor/sqrt(2) * ((1+2/pi)*sin(pi/
(4*roll_off_factor)) + (1-2/pi)*cos(pi/(4*roll_off_factor)));
else
N= sin(pi*t * (1-roll_off_factor)/Ts) + 4*roll_off_factor*t *
cos(pi*t*(1+roll_off_factor)/Ts)/Ts;
D= pi*t * (1-(4*roll_off_factor*t/Ts)^2)/Ts;
p(Index)=N/D;
end
Index=Index+1;
end
figure
subplot(211)
plot(interval,p);
xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Root
raised cosine filter'); grid on
p_kTs=conv(p,p);
hold on
interval=-T:Ts:T;
subplot(212)
plot(interval,p_kTs);
xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Raised
cosine filter'); grid on
axis ([-5*Ts 5*Ts -2 10])
%% Problem # 2
m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1
oversampled_data=upsample(m,T/Ts);
figure;
subplot(311);
stem(oversampled_data);
axis ([200 300 -2 2])
xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on
Tx=conv(oversampled_data,p);
subplot(312)
plot(Tx);
axis ([200 300 -2 2])
xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on
subplot(313);
spec_Tx=fft(Tx,length(Tx));
plot(abs(spec_Tx));
xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid
on
%% Problem #3
m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1
c=upsample([1 0.5 -0.1],T/Ts);
h=conv(c,p);
oversampled_data=upsample(m,T/Ts);
figure;
subplot(311);
stem(oversampled_data);
axis ([200 300 -2 2])
xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on
Tx=conv(oversampled_data,h);
7. subplot(312)
plot(Tx);
axis ([200 300 -2 2])
xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on
subplot(313);
spec_Tx=fft(Tx,length(Tx));
plot(abs(spec_Tx));
xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid
on
%% Problem #4 BPSK
[x y]=size(Tx);
j=1;
m=(m+1)/2;
for i=SNR
sgma=sqrt(10^(-i/10));
noise=random('Normal',0,sgma,x,y);
Rx=noise+Tx;
r_k=conv(Rx,fliplr(h));
r=r_k(80:end-79);
rx=sign(downsample(r,T/Ts));
rx=(rx+1)/2;
[N,ber]=biterr(m,rx);
e_bpsk(j)=ber;
j=j+1;
end
% Problem #4 4-QAM
rl=1/sqrt(2)*randsrc(M,1,[-1 1;0.5 0.5]); mg=1/sqrt(2)*randsrc(M,1,[-1 1;0.5
0.5]); % BPSK Symbols 1,-1
m=rl+mg*1j; % 4-QAM symbols
oversampled_data=upsample(m,T/Ts);
Tx=conv(oversampled_data,h);
[x y]=size(Tx); j=1;
rl=(sqrt(2)*rl+1)/2; mg=(sqrt(2)*mg+1)/2;
for i=SNR
sgma=sqrt(10^(-i/10));
noise=random('Normal',0,sgma,x,y)+random('Normal',0,sgma,x,y)*1j;
Rx=noise+Tx;
r_k=conv(Rx,fliplr(h));
r=r_k(80:end-79);
rxr=sign(downsample(real(r),T/Ts)); rxm=sign(downsample(imag(r),T/Ts));
rxr=(rxr+1)/2; rxm=(rxm+1)/2;
[N,ber1]=biterr(rl,rxr); [N,ber2]=biterr(mg,rxm);
e_4qam(j)=(ber1+ber2)/2;
j=j+1;
end
figure;
semilogy(SNR,e_bpsk,'-o');
hold on;
semilogy(SNR,e_4qam,'-*');
legend('BPSK', '4-QAM'); xlabel('SNR in dB'); ylabel('BER');
title('BER comparison of BPSK and 4-QAM in MLSD detector'); grid on