Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

SERof BPSK from simulation using MATLAB

Status
Not open for further replies.

saeddawoud

Full Member level 3
Joined
Apr 27, 2007
Messages
159
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
2,166
BPSK Simulation

Hello,

I am new to simulation using MATLAB, so I need a simple and clear code illustrating the idea. Can you, please, post how to find the SER of BPSK modulation over Rayleigh fading channels?

Thanks in advance
 

jvinoth

Newbie level 1
Joined
Jan 8, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,296
%BPSK simulation using a carrier cosine wave with ISI
clc;
close all;
clear all;
%figure(1)
n=160
for i=1:n
data(i)= 2*round(rand)-1;
end
%create modulated BPSK signal
%first expand the bit stream
exdata=[];
for i=1:length(data)
for rep=1:5
exdata= [exdata data(i)];
end
end
ts=.1;
t=1:ts:80.9;
carrier=cos(pi*t);
%multiply expanded bitstream by cosine wave with carrier frequency
%this is the BPSK that is to be transmitted over the channel
bpsk=carrier.*exdata;
%bpsk=[bpsk(length(bpsk)-1) bpsk(length(bpsk)) bpsk];
%plot(bpsk)
% generating the noise
% p=rand(1,800)*2*pi;
p=rand*2*pi;
snr=10;
r=sqrt(-1*(1/snr*log(1 - rand)));
% no = 5*(r.* exp(j*p));
no = (r.* exp(j*p));
% value of alpha
al=rand+j*rand;
%al=1;
% Spreading channel with the alpha as the variable
for k=5:5:795
for l = 1:5
%al=round(rand)+j*round(rand)
rec(k+l)=bpsk(k+l)+al*bpsk(k-5+l);
end
end
rxdata=rec+ no ;
%begin demodulation
%first multiply recieved bitstream by cosine wave with carrier frequency
%figure(2)
uncarry=rxdata.*carrier;
%plot(uncarry)
%demodulate by integrating
dec1=[];
for inc=1:5:length(uncarry)
dec=trapz(inc:inc+4,uncarry(inc:inc+4));
dec1=[dec1 dec];
end
%make decision with a threshold of zero
demod=[];
for i=1:length(dec1)
if dec1(i)>0
demod=[demod 1];
else
demod=[demod -1];
end
end
%stem(demod)
%calculate errors
error=0;
for i=1:length(demod)
if data(i)~=demod(i)
error=error+1;
end
end
error
ber=error/n
figure(3)
title('Comparing the Bits at transmitter and receiver')
stem(data)
hold
stem(demod,'rx')
 

saeddawoud

Full Member level 3
Joined
Apr 27, 2007
Messages
159
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
2,166
jvinoth said:
%BPSK simulation using a carrier cosine wave with ISI
clc;
close all;
clear all;
%figure(1)
n=160
for i=1:n
data(i)= 2*round(rand)-1;
end
%create modulated BPSK signal
%first expand the bit stream
exdata=[];
for i=1:length(data)
for rep=1:5
exdata= [exdata data(i)];
end
end
ts=.1;
t=1:ts:80.9;
carrier=cos(pi*t);
%multiply expanded bitstream by cosine wave with carrier frequency
%this is the BPSK that is to be transmitted over the channel
bpsk=carrier.*exdata;
%bpsk=[bpsk(length(bpsk)-1) bpsk(length(bpsk)) bpsk];
%plot(bpsk)
% generating the noise
% p=rand(1,800)*2*pi;
p=rand*2*pi;
snr=10;
r=sqrt(-1*(1/snr*log(1 - rand)));
% no = 5*(r.* exp(j*p));
no = (r.* exp(j*p));
% value of alpha
al=rand+j*rand;
%al=1;
% Spreading channel with the alpha as the variable
for k=5:5:795
for l = 1:5
%al=round(rand)+j*round(rand)
rec(k+l)=bpsk(k+l)+al*bpsk(k-5+l);
end
end
rxdata=rec+ no ;
%begin demodulation
%first multiply recieved bitstream by cosine wave with carrier frequency
%figure(2)
uncarry=rxdata.*carrier;
%plot(uncarry)
%demodulate by integrating
dec1=[];
for inc=1:5:length(uncarry)
dec=trapz(inc:inc+4,uncarry(inc:inc+4));
dec1=[dec1 dec];
end
%make decision with a threshold of zero
demod=[];
for i=1:length(dec1)
if dec1(i)>0
demod=[demod 1];
else
demod=[demod -1];
end
end
%stem(demod)
%calculate errors
error=0;
for i=1:length(demod)
if data(i)~=demod(i)
error=error+1;
end
end
error
ber=error/n
figure(3)
title('Comparing the Bits at transmitter and receiver')
stem(data)
hold
stem(demod,'rx')
Hello jvinoth,

Thank you for replying, but can you add some comments on the above code for better understanding.

Thanks in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top