In: Electrical Engineering
Understand the principles of Quadrature Phase Shift Keying (QPSK). Measure Bit Error Rate (BER). Understand the effects of having phase errors in the received signal.
i need matlab code for qpsk modulation and demodulation both
also bit rate error using of the recived signal
i repeat i need matklab code for all task
1) qpsk modulation
2) qpsk demodulation
3) ber bit eroor rate matlab code
Qpsk Modulation and Demodulation
clc;
close all;
Bits=input('Enter bit stream to be modulated : '); %
information
%Number_of_bit=1024;
%data=randint(Number_of_bit,1);
subplot(3,2,1)
stem(Bits, 'linewidth',2)
grid on;
title(' Information bits to be transmitted ');
data_NZR=2*Bits-1; % Data Represented at NZR form for QPSK
modulation
s_p_data=reshape(data_NZR,2,length(Bits)/2); % S/P convertion of
data
br=10.^6; %Let us transmission bit rate 1000000
f=br; % minimum carrier frequency
T=1/br; % bit duration
t=T/99:T/99:T; % Time vector for one bit information
% QPSK modulation
Y=[];
Y_in=[];
Y_qd=[];
for(i=1:length(Bits)/2)
Y1=s_p_data(1,i)*cos(2*pi*f*t); % in phase component
Y2=s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component
Y_in=[Y_in Y1]; % inphase signal vector
Y_qd=[Y_qd Y2]; %quadrature signal vector
Y=[Y Y1+Y2]; % modulated signal vector
end
Tx_sig=Y; % transmitting signal after modulation
tt=T/99:T/99:(T*length(Bits))/2;
subplot(3,2,2)
plot(tt,Y_in,'r'), grid on;
title( 'Inphase component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt)');
subplot(3,2,3)
plot(tt,Y_qd,'g'), grid on;
title(' Quadrature component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt)');
subplot(3,2,4)
plot(tt,Tx_sig,'r'), grid on;
title('QPSK modulated signal');
xlabel('time(sec)');
ylabel(' amplitude(volt)');
% QPSK demodulation
Rx_data=[];
Rx_sig=Tx_sig; % Received signal\
for(i=1:1:length(Bits)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig((i-1)*length(t)+1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received & inphase
carred signal
Z_in_intg=(trapz(t,Z_in))*(2/T);% integration using trapezoidal
rule
if(Z_in_intg>0) % Decision Maker
Rx_in_data=1;
else
Rx_in_data=0;
end
%%XXXXXX Quadrature coherent dector XXXXXX
Z_qd=Rx_sig((i-1)*length(t)+1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived & Quadphase
carred signal
Z_qd_intg=(trapz(t,Z_qd))*(2/T);% integration using trapezoidal
rule
if (Z_qd_intg>0)% Decision Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end
Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received Data
vector
end
subplot(3,2,5)
stem(Rx_data,'r','linewidth',3)
title('Information after Receiveing ');
grid on;
Result:
Enter bit stream to be modulated : [1 0 1 1 0 1 1 0 0 1]
MATLAB CODE FOR BER
clc;
clear all;
close all;
%for the values of SNR in dB for 0 to 10
snr_db=0:10;
snr=10.^(snr_db/10);
qpsk = (1/2)*erfc(sqrt(snr));
%Plotting all the BER curves in semilog graph
semilogy(snr_db,qpsk);
xlabel('Eb/No in dB');
ylabel('SNR in dB');
title('BER Analysis QPSK ');