0% found this document useful (0 votes)
242 views6 pages

PSD of BPSK, QPSK, MSK, FSK and Comparison of BPSK, QPSK, and MSK

This document contains MATLAB code to analyze and compare the power spectral densities (PSDs) of BPSK, QPSK, and MSK modulation schemes. It calculates the theoretical PSD formulas for each modulation type and plots them on a normalized dB scale. It also contains code to analyze the orthogonality of signals and calculate the bit error rate (BER) of a binary transmission over an additive white Gaussian noise (AWGN) channel for varying signal-to-noise ratio (SNR) values.

Uploaded by

rahulsporty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
242 views6 pages

PSD of BPSK, QPSK, MSK, FSK and Comparison of BPSK, QPSK, and MSK

This document contains MATLAB code to analyze and compare the power spectral densities (PSDs) of BPSK, QPSK, and MSK modulation schemes. It calculates the theoretical PSD formulas for each modulation type and plots them on a normalized dB scale. It also contains code to analyze the orthogonality of signals and calculate the bit error rate (BER) of a binary transmission over an additive white Gaussian noise (AWGN) channel for varying signal-to-noise ratio (SNR) values.

Uploaded by

rahulsporty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PSD of BPSK, QPSK, MSK, FSK and comparison of BPSK, QPSK, and MSK

clear all;

Eb = 5;
fc = 8e3;
rb = 1.25e3;
delf = 3e3;
tb = 1/rb;
N = 1000;

%% PSD BPSK
% method 1: formula
Tb = 1*tb;

f = -(fc+delf):(2*(fc+delf))/(N-1):fc+delf;
% psd = 2*Eb.*power(sinc(Tb.*f),2);

psd_pb = (1/4).*((2*Eb.*power(sinc(Tb.*(f-
fc)),2))+(2*Eb.*power(sinc(Tb.*(f+fc)),2)));
psd_pb = psd_pb./max(psd_pb);
psd_bpsk = 10*log10(psd_pb);

subplot(2,2,1);
plot(f, 10*log10(psd_pb),'k');
xlabel('Frequency [Hz]');
ylabel('Normalized PSD(f) [dB/Hz]');
title('PSD of BPSK');
grid on;

%% PSD QPSK
Tb = 2*tb;
% psd = 2*Eb.*power(sinc(Tb.*f),2);

psd_pb = (1/4).*((2*2*Eb.*power(sinc(Tb.*(f-
fc)),2))+(2*2*Eb.*power(sinc(Tb.*(f+fc)),2)));
psd_pb = psd_pb./max(psd_pb);
psd_qpsk = 10*log10(psd_pb);

subplot(2,2,3);
plot(f, 10*log10(psd_pb),'k');
xlabel('Frequency [Hz]');
ylabel('PSD(f) [dB/Hz]');
title('Normalized PSD of QPSK');
grid on;

%% PSD of MSK

Tb = tb;
psd1 = (64/pi^2).*(Eb.*power((cos(2*pi*Tb.*f)),2))./power((1-
(16.*f.*f*Tb*Tb)),2);
psd_pb = (1/4).*((32/pi^2).*(2*Eb.*power((cos(2*pi*Tb.*(f-
fc))),2))./power((1-(16.*(f-fc).*(f-fc)*Tb*Tb)),2) +
(32/pi^2).*(2*Eb.*power((cos(2*pi*Tb.*(f+fc))),2))./power((1-
(16.*(f+fc).*(f+fc)*Tb*Tb)),2));

psd_pb = psd_pb./max(psd_pb);
psd_msk = 10*log10(psd_pb);

subplot(2,2,2);
plot(f, 10*log10(psd_pb),'k');
xlabel('Frequency [Hz]');
ylabel('Normalized PSD(f) [dB/Hz]');
title('PSD of MSK');
grid on;

%% PSF FSK
Tb = 1*tb;

fc1 = 9e3;
fc2 = 7e3;

fc = max(fc1,fc2);

f = -(fc+delf):(2*(fc+delf))/(N-1):fc+delf;
% psd = 2*Eb.*power(sinc(Tb.*f),2);

psd_pb1 = (1/4).*((2*Eb.*power(sinc(Tb.*(f-
fc1)),2))+(2*Eb.*power(sinc(Tb.*(f+fc1)),2)));
psd_pb2 = (1/4).*((2*Eb.*power(sinc(Tb.*(f-
fc2)),2))+(2*Eb.*power(sinc(Tb.*(f+fc2)),2)));

psd_pb = psd_pb1 + psd_pb2;


psd_pb = psd_pb./max(psd_pb);

subplot(2,2,4);
plot(f, 10*log10(psd_pb),'k');
xlabel('Frequency [Hz]');
ylabel('Normalized PSD(f) [dB/Hz]');
title('PSD of FSK');
grid on;

%%
figure;
plot(f, psd_bpsk, 'k', f, psd_qpsk, 'b', f, psd_msk, 'r');
legend('BPSK', 'QPSK', 'MSK');
xlabel('Frequency [Hz]');
ylabel('Normalized PSD(f) [dB/Hz]');
title('Comaprison of PSDs');
Study of orthogonal signals

clear all;

fs=100; %sampling frequency


T=0.2; %width of the rectangule pulse in seconds

t=-0.5:1/fs:0.5; %time base

x=rectpuls(t,T); %generating the square wave


x1=x .* exp(1j*2*pi*(t/T));

subplot(2,1,1);
plot(t,x,'k',t,x1,'r');
legend('Signal 1', 'Signal 2 (Exponential muliplied)');
title(['Pulse width=', num2str(T),'s and its exponential multiple time
domain']);
xlabel('Time(s)');
ylabel('Amplitude');
grid on;

L=length(x);
NFFT = 1024;
X = fftshift(fft(x,NFFT)); %FFT with FFTshift for both negative & positive
frequencies
X1 = fftshift(fft(x1,NFFT));
f = fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector

subplot(2,1,2);
plot(f,abs(X)/L,'k',f,abs(X1)/(L),'r');
legend('Signal 1', 'Signal 2 (orthogonal)');
title('Magnitude of FFT of orthogonal signals (1/T) separated');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
grid on;
Study of BER of AWGN channel

clear all;

m_r = rand(1,12000);
m_t = zeros(1,12000);
for num=1:1:size(m_r,2)
if m_r(num) > 0.5
m_t(num) = 1;
else
m_t(num) = 0;
end
end

s_snr = 1:1:30;
count_error = zeros(1,size(s_snr,2));
prob_error = zeros(1,size(s_snr,2));

for snr = 1:1:30

y = awgn(m_t, snr);

for num=1:1:size(y,2)
if y(num) > 0.5
y(num) = 1;
else
y(num) = 0;
end
end
error = abs(y - m_t);
count_err = 0;

for num=1:size(error,2)
if error(num)>0
count_error(snr) = count_error(snr) + 1;
end
end
prob_error(snr) = count_error(snr)/size(m_t,2);

end
a=1;
semilogy(s_snr,prob_error,'k');
xlabel('SNR [dB]');
ylabel('BER');
title('BER v/s SNR for Binary AWGN Channel')
grid on;

You might also like