0% found this document useful (0 votes)
23 views2 pages

All All 'State' 'State'

This MATLAB code simulates binary phase-shift keying (BPSK) modulation over an additive white Gaussian noise (AWGN) channel. It generates 1000 random bits, maps them to BPSK symbols, adds noise at varying signal-to-noise ratios, performs decision decoding, and counts the bit errors. The theoretical and simulated bit error rates are plotted against Eb/N0 and an eye diagram is shown for the highest SNR case.

Uploaded by

joko
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)
23 views2 pages

All All 'State' 'State'

This MATLAB code simulates binary phase-shift keying (BPSK) modulation over an additive white Gaussian noise (AWGN) channel. It generates 1000 random bits, maps them to BPSK symbols, adds noise at varying signal-to-noise ratios, performs decision decoding, and counts the bit errors. The theoretical and simulated bit error rates are plotted against Eb/N0 and an eye diagram is shown for the highest SNR case.

Uploaded by

joko
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/ 2

MATLAB Code:

clc

clearall

closeall

N = 1000% Number of bitsrand('state',100);% initializing rand function

randn('state',200);% initializing randn function

% Transmitter

ip = rand(1,N)>0.5;% generating input bits 0,1

s = 2*ip-1;% BPSK modulation 0 -> -1; 1 -> 1n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)];% White gaussian noise, 0dB
varianceEb_N0_dB= [-5:10];% multiple Eb/N0 values

forii = 1:length(Eb_N0_dB)

% Noise addition

y = s + 10^(-Eb_N0_dB(ii)/20)*n;% Additive White Gaussian Noise

% Receiver - decision decoding

ipHat = real(y)>0;

% Counting the errors

nErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N;% BER by counting errors manually

theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10)));% BER by using formula

% Plot for Eb/No vs BER

closeall

figure

semilogy(Eb_N0_dB,theoryBer);

gridon

xlabel('Eb/No in dB');

ylabel('Bit Error Rate');

title('Eb/No vs BER Curve');

% Eye Diagram for Signal with Highest Value of Eb/No

eyediagram(y,2);

You might also like