Clear Filters
Clear Filters

BER calculation BPSK simulation with Rayleigh channel

16 views (last 30 days)
Hello! I am writing the simulaton code for BPSK simulation with Rayleigh channel.My results are far from the theoretical. If anyone can help me to find the problem, I'll apreciate.
Many thanks, Den.
Here is my code:
function [ bs ] = bpskray2 ( EbNo )
% Define parameters.
M = 2; % Size of signal constellation
k = log2(M); % Number of bits
per symbol
n = 3e6; % Number of bits to process = 3,000,000
nsamp = 1; % Oversampling rate
%%Signal Source
% Create a binary data stream
data = randint(n,1); % Random binary data stream
% Create an Rayleigh channe object
rayChanObj = rayleighchan;
% Create an error rate calculator
hError = comm.ErrorRate;
% Create a BPSK modulator System object
hModulator = comm.BPSKModulator;
% Create a BPSK demodulator System object
hDemodulator = comm.BPSKDemodulator;
for i= 0:EbNo
% Modulate the data
modData = step(hModulator, data);
% Send signal over an AWGN channel.
snr = i + 10*log10(k) - 10*log10(nsamp);
% Apply channel object on the modulated data using the FILTER function
%%BER Calculation
ber = step(hError, x, demodData);
xlabel('Eb/No [dB]');
axis([0 EbNo(length(EbNo)) 1e-8 .9]);
title('Bit error probability curve for BPSK modulation');
legend ('BER');
grid on;

Answers (1)

Veera Kanmani
Veera Kanmani on 20 Apr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!