0% found this document useful (0 votes)
56 views

System Simulation Over Awgn Using BPSK Modulation Part I: MATLAB Environment

This document describes how to simulate and analyze the bit error rate (BER) performance of binary phase-shift keying (BPSK) modulation over an additive white Gaussian noise (AWGN) channel using MATLAB. It provides the MATLAB code to generate BPSK symbols, transmit over an AWGN channel, detect symbols at the receiver, and calculate the BER. It also provides the theoretical BER calculation. The document explains that the standard deviation of the noise is set as E/√(2SNR) in the simulation, where E is the symbol energy and SNR is the signal-to-noise ratio. It further describes modifying the code to simulate quadrature phase-shift keying (QPSK) modulation.

Uploaded by

Pooja Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
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)
56 views

System Simulation Over Awgn Using BPSK Modulation Part I: MATLAB Environment

This document describes how to simulate and analyze the bit error rate (BER) performance of binary phase-shift keying (BPSK) modulation over an additive white Gaussian noise (AWGN) channel using MATLAB. It provides the MATLAB code to generate BPSK symbols, transmit over an AWGN channel, detect symbols at the receiver, and calculate the BER. It also provides the theoretical BER calculation. The document explains that the standard deviation of the noise is set as E/√(2SNR) in the simulation, where E is the symbol energy and SNR is the signal-to-noise ratio. It further describes modifying the code to simulate quadrature phase-shift keying (QPSK) modulation.

Uploaded by

Pooja Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 5

PROJECT

SYSTEM SIMULATION OVER AWGN USING BPSK MODULATION


.
Part I: MATLAB Environment
This exercise will guide you to realize the basic operating environment. Some useful instructions will also
be introduced. As MATLAB is executed, the MATLAB desktop window will be shown.

All instructions can be looked up and executed in the Command Window. We encourage you to use help
as much as possible and trace the relative instructions at the same time. Command Window is convenient
for execution and finding the immediate results. If a series of instructions are going to be executed, it is
necessary to edit the .m file. Here are some useful constants and instructions. Try to explain and reveal how
they work.

i j pi eps inf
nan realmax realmin length reshape
conj ones zeros tic、toc clock
profile plot stem awgn sin
sum mean fft clc clear
close figure for while switch
if size fliplr conv randn
rand
Part II: Constellation
In modulation systems, each scheme has different error performance. Assume that 108 random bits are
transmitted. In the transmission process, additive white Gaussian noise (AWGN) is involved in the original
data. Encode them according to BPSK, QPSK, and 16-PSK, and the constellation is depicted as figure 2.

Part III:
Vector and Matrices Creation of variables: Call for values:
>> v = zeros(1, 5) >> v ( or v(:) )
>> m = ones(2, 2) >> v(5)
>> v = [1 2 4 8 16] >> w(2:4)
>> w = [ 0: 0.5 : 3 ] >> m(1,2)
>> m = [0.1 0.3 ; 0.2 3] >> m(:,1)
Plots & Figures
>> dB = 0: 0.1: 10;
>> SNR = 10.^ (db ./ 10);
>> Pb = 0.5 * erfc(sqrt(SNR));
>> semilogy (dB, Pb);
>> % same as: plot(dB, log10(Pb));
>> grid on;
>> xlabel(‘SNR (dB)’);
>> ylabel(‘Bit error rate’);
>> title(‘Performance of antipodal signal over AWGN channel’);
􀂾 Several plots in one figure:
>> x = [0: 0.05: 2*pi];
>> figure(1);
>> subplot(1, 2, 1); plot(x, sin(x));
>> title(‘sin’); grid on; axis([0 2*pi -1 1]);
>> subplot(1, 2, 2); plot(x, cos(x));
>> title(‘cos’); grid on; axis([0 2*pi -1 1]);
􀂾 Other commands: (check help)
􀂄 figure, axis, stem, bar, legend, hold,…

For loops
>> B = [[1 2 3]’ [3 2 1]’ [2 1 3]’];
>> for j = 2: 3
for i = j: 3
B(i,:) = B(i,:) - B(j-1,:) * B(i,j-1) / B(j-1,j-1);
end
end
􀂾 Avoid loops in your program. Use reasonable vector operation instead
if possible.
􀂾 Make operations inside loops as few as possible.
MATLAB Files
􀂾 MATLAB script (executable) files (M-file):
􀂄 Edit it in any text editor.
􀂄 Save it with extension ‘.m’ (say ‘hello.m’)
􀂄 Type file name (‘hello’) to start running.
􀂾 MATLAB data file (mat-file)
>> save result.mat dB , Pb % save variables dB and Pb in result.mat
>> load result.mat % load file
>> whos % check what variables are loaded
Note: MATLAB execution files must end with ‘.m’. Likewise data files end with ‘.mat’. Be sure to be
in the appropriate directory to access files.
Exercise
Instructions:
You have to hand in the report on time. In your report, you should answer the following three questions.
(a) Execute the attached MATLAB programs to perform estimate and plot the error probability performance
(bit error rate vs SNR(dB)) of a binary antipodal (BPSK) communication system. In your figure, you should
show 2 curves:
(i)The result by simulation.
(ii)The results by analysis.
Note your curve is (log scale in Y axis for BER and X axis for SNR).
(b) Understand the programs and explain why “sgma=E/sqrt(2*SNR)” is used in subroutine bpsk_sim.m
(c) Modify the code to plot the error probability performance of a QPSK communication system. In your
figure, you should show the result by simulation.
Source code
BPSK.m
% MATLAB script for BPSK Performance in AWGN Channel (Simulation and Theoretical Analysis)
SNRindB1=0:1:10;
SNRindB2=0:0.1:10;
echo on;
for i=1:length(SNRindB1),
% simulated error rate
smld_err_prb(i)=bpsk_sim(SNRindB1(i));
echo off;
end;
echo on;
for i=1:length(SNRindB2),
SNR=exp(SNRindB2(i)*log(10)/10);
% theoretical error rate
theo_err_prb(i)=Qfunct(sqrt(2*SNR));
echo off;
end;
echo on;
% Plotting commands follow
semilogy(SNRindB1,smld_err_prb,'*');
hold
semilogy(SNRindB2,theo_err_prb);
xlabel('Eb/N0');
ylabel('Pb');
bpsk_sim.m
function [p]=bpsk_sim(snr_in_dB)
%[p]=bpsk_sim(snr_in_dB)
%simulates the probability of error for the particular
%value of snr_in_dB, signal to noise ratio in dB.
E=1;
SNR=exp(snr_in_dB*log(10)/10);
% signal to noise ratio
sgma=E/sqrt(2*SNR);
% sigma, standard deviation of noise
N=10000;
% generation of the binary data source follows
for i=1:N,
temp=rand; % a uniform random variable over (0,1)
if (temp<0.5),
dsource(i)=0;
% with probability 1/2, source output is 0
else
dsource(i)=1;
% with probability 1/2, source output is 1
end
end;
% the detection, and probability of error calculation
for i=1:N,
% The matched filter outputs
if (dsource(i)==0),
r=-E+sgma*randn(1,1);
% if the source output is "0"
else
r=E+sgma*randn(1,1);
% if the source output is "1"
end;
% detector follows
if (r<0),
decis=0; % decision is "0"
else
decis=1; % decision is "1"
end;
if (decis~=dsource(i)),
% if it is an error, increase the error counter
numoferr=numoferr+1;
end;
end;
p=numoferr/N;
% probability of error estimate
Qfunct.m
function [y]=Qfunct(x)
%[y]=Qfunct(x)
%QFUNCT evaluates the Q-function.
%y = 1/sqrt(2*pi) * integral from x to inf of exp(-t^2/2) dt.
%y = (1/2) * erfc(x/sqrt(2)).
y=(1/2)*erfc(x/sqrt(2));

You might also like