Eb/No (SNR) Vs BER Curve Plotting for BPSK in AWGN Channel : Error Probability Curve For BPSK

In digital communication, during transmission the bits usually gets altered, i.e., the transmitted '1' is interpreted as '0' & transmitted '0' is interpreted as '1', this constitutes as a bit error. This happens due to various factors, like noise, fading etc. The bit error rate (BER) is the number of bit errors divided by the total number of transmitted bits over a channel. BER although unit-less also expressed in terms of percentage.
E.g., let the transmitted bit sequence:
1 1 1 0 0 0 1 1 1 0
& the received bit sequence:
1 1 0 0 1 0 1 1 0 0 ,
Then the number of bit errors in this case is 3. The BER is 3 incorrect bits divided by 10 transmitted bits, resulting in a BER of 0.3 or 30%.

That was a bit about BER, now something about AWGN channel,
Additive white Gaussian noise (AWGN) is a basic channel model used to study the effect of  random processes that occurs in nature.
  • Its assumed to be 'Additive', so the modelling will be easy.
  • 'White' refers to idea that it has uniform power across the frequency band.
  • 'Gaussian' because it has a normal distribution in the time domain, with average value zero.
The central limit theorem also states that the summation of large number of random processes will tend to have Gaussian or Normal distribution.

MATLAB Implementation:
In the given example below, we have generated 100000 bits in order to have enough number of bits to generate a nearly real life curve. Also for each SNR value we have waited for 100 bit errors to occur before proceeding to the other SNR value, as to save the execution time. Later on all the bit errors that occurred are added & the number of bits generated are also added & divided by the former to obtain BER.
In the same curve we have compared the simulation result with the theoretical result as well. 

MATLAB Code for Eb/No (SNR) Vs BER Curve Plotting for BPSK in AWGN Channel:
clear all
close all
bit_count = 100000;
%no. of random bits to be generated for a single shot of BER calculation
SNR = 0: 1: 10; %Range of SNR over which to simulate
for k = 1: 1: length(SNR)
    tote = 0;
%total error bits
    totb = 0;
%total bits
    while tote < 100
%until you get 100 errors
        rbits  = round(rand(1,bit_count));
%generate random bits
        tx = -2*(rbits-0.5);
% BPSK Modulation: Directly to Bipolar NRZ
        N0 = 1/10^(SNR(k)/10);
%noise level
        rx = tx + sqrt(N0/2)*(randn(1,length(tx))+i*randn(1,length(tx)));
        rx2 = rx < 0;
% BPSK demodulator logic at the Receiver
        diff = rbits - rx2;
% Calculate Bit Errors
        tote = tote + sum(abs(diff));
%total errors
        totb = totb + length(rbits); %total bits generated
    BER(k) = tote / totb;
% Calculate Bit Error Rate
hold on;
xlabel('Eb/No (dB)');
title('Eb/No(SNR) Vs BER plot for BPSK Modualtion in AWGN Channel');
thber = 0.5*erfc(sqrt(10.^(SNR/10)));
% Theoretical BER
grid on;
legend('Simulated Curve', 'Theoretical Curve');

Result of above Code:
Eb/No (SNR) Vs BER Curve Plotting for BPSK in AWGN Channel
Eb/No (SNR) Vs BER Curve Plotting for BPSK in AWGN Channel