1 Star2 Stars3 Stars4 Stars5 Stars (62 votes, average: 4.16 out of 5)
Loading ... Loading ...
Print Print

Bit Error Rate (BER) for BPSK modulation

by Krishna Sankar on August 5, 2007

In this post, we will derive the theoretical equation for bit error rate (BER) with Binary Phase Shift Keying (BPSK) modulation scheme in Additive White Gaussian Noise (AWGN) channel. The BER results obtained using Matlab/Octave simulation scripts show good agreement with the derived theoretical results.

With Binary Phase Shift Keying (BPSK), the binary digits 1 and 0 maybe represented by the analog levels and respectively. The system model is as shown in the Figure below.

Figure: Simplified block diagram with BPSK transmitter-receiver

Channel Model

The transmitted waveform gets corrupted by noise , typically referred to as Additive White Gaussian Noise (AWGN).

Additive : As the noise gets ‘added’ (and not multiplied) to the received signal

White : The spectrum of the noise if flat for all frequencies.

Gaussian : The values of the noise follows the Gaussian probability distribution function, with and .

Computing the probability of error

Using the derivation provided in Section 5.2.1 of [COMM-PROAKIS] as reference:

The received signal,

when bit 1 is transmitted and

when bit 0 is transmitted.

The conditional probability distribution function (PDF) of for the two cases are:

.

Figure: Conditional probability density function with BPSK modulation

Assuming that and are equally probable i.e. , the threshold 0 forms the optimal decision boundary.

  • if the received signal is is greater than 0, then the receiver assumes was transmitted.
  • if the received signal is is less than or equal to 0, then the receiver assumes was transmitted.

i.e.

and

.

Probability of error given was transmitted

With this threshold, the probability of error given is transmitted is (the area in blue region):

,

where,

is  the complementary error function.

Probability of error given was transmitted

Similarly the probability of error given is transmitted is (the area in green region):

.

Total probability of bit error

.

Given that we assumed that and are equally probable i.e. , the bit error probability is,

.

Simulation model

Matlab/Octave source code for computing the bit error rate with BPSK modulation from theory and simulation. The code performs the following:

(a) Generation of random BPSK modulated symbols +1′s and -1′s

(b) Passing them through Additive White Gaussian Noise channel

(c) Demodulation of the received symbol based on the location in the constellation

(d) Counting the number of errors

(e) Repeating the same for multiple Eb/No value.

Click here to download Matlab/Octave script for simulating BER for BPSK modulation in AWGN chnanel.

Figure: Bit error rate (BER) curve for BPSK modulation – theory, simulation

Reference

[DIGITAL COMMUNICATION: PROAKIS] Digital Communications by John Proakis

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.

{ 519 comments… read them below or add one }

Randal August 18, 2014 at 11:21 am

If some one wishes expert view concerning blogging after that i
suggest him/her to visit this weblog, Keep up the fastidious work.

Reply

Check That August 14, 2014 at 2:18 am

Hey there, I think your site might be having browser compatibility issues.
When I look at your blog site in Ie, it looks
fine but when opening in Internet Explorer, it has
some overlapping. I just wanted to give you a quick heads up!
Other then that, wonderful blog!

Reply

La Planète des singes l'affrontement gratuit August 13, 2014 at 5:36 pm

Compare and contrast your choices to decide what will work
best for your room and budget. The style of a well used movie theater can be carried out using the structural arranging as part
of your room. Hence, the people are well educated and highly concerned about the development of
the region and keenly look forward to make their lives always easy.

Reply

wildstar leveling warrior August 11, 2014 at 6:58 am

Thankѕ very nice blog!

Reply

pink July 30, 2014 at 12:10 pm

can you tell me how to plot snr vs distance for a channel having path loss model??

Reply

dieta jadłospis July 9, 2014 at 9:18 am

Heya! I realize this is somewhat off-topic however I had to ask.
Does operating a well-established blog such as yours take a lot of work?
I am completely new to blogging but I do write in my diary
every day. I’d like to start a blog so I can easily share my experience and feelings online.

Please let me know if you have any ideas or tips for new aspiring blog owners.
Thankyou!

Reply

interesting news June 30, 2014 at 6:39 pm

I am not sure where you’re getting your info, but good topic.
I needs to spend some time learning much more or understanding more.

Thanks for wonderful information I was looking for this info for my mission.

Reply

agen judi terpercaya June 24, 2014 at 7:10 am

Very quickly this site will be famous among all blog visitors, due to it’s good articles

Reply

pendapat tentang judi June 23, 2014 at 1:59 am

Having read this I thought it was very informative. I appreciate you spending some time and energy to put this informative article together.
I once again find myself personally spending a significant amount of time
both reading and leaving comments. But so what, it was still
worth it!

Reply

dubai arabic escort June 21, 2014 at 7:07 am

Hurrah! Finally I got a website from where I be capable of
actually get valuable data concerning my study and knowledge.

Reply

Diana June 20, 2014 at 9:28 am

In flash watch dogs serial games on their
websites. It is possible to alter the features of the latest and greatest weakness: other people.
What is your dog? Moreover, people have adapted to what
additional features the addition of the best! 11, they have a
behavior or a curse, fuelling its powerhouse economy while
trapping its young in addictive fantasy worlds.

Reply

lawyer job satisfaction June 19, 2014 at 3:47 pm

Fantastic blog! Do you have any suggestions for aspiring
writers? I’m hoping tto start mmy own blog soon but I’m a little lost on everything.
Would you suggeat starging with a free platform like
Wordpress or go for a paid option? There are
so many choices out there that I’m totally confused
.. Any ideas? Kudos!

Reply

Audubon Wildflowers Calendar 2010 download mobi June 14, 2014 at 5:50 am

Unquestionably believe that which you said. Your favorite reason seemed to be on the web the easiest thing to
be aware of. I say to you, I certainly get annoyed while people
consider worries that they plainly don’t know about. You managed
to hit the nail upon the top as well as defined out the whole
thing without having side-effects , people can take a signal.
Will probably be back to get more. Thanks

Reply

84, Charing Cross Road download mobi June 13, 2014 at 3:17 am

I comment whenever I like a article on a site or I have something to valuable to
contribute to the discussion. It is triggered by the fire communicated in the post I read.
And on this article Bit Error Rate (BER) for BPSK modulation. I was
moved enough to leave a comment :) I actually do have a couple
of questions for you if it’s okay. Could it be just me or does
it give the impression like a few of these responses
look as if they are written by brain dead individuals?
:-P And, if you are posting on other places, I would
like to keep up with everything fresh you have to post. Would you
list every one of your shared pages like your linkedin profile,
Facebook page or twitter feed?

Reply

hormigon en talavera June 12, 2014 at 2:39 pm

I am in fact delighted to read this website posts which carries tons of useful information, thanks for providing these kinds of data.

Reply

minecraft mods download June 6, 2014 at 6:36 pm

Howdy! This post couldn’t be written much better! Reading through this article reminds me of my previous roommate!
He constantly kept preaching about this. I will forward this post to him.
Fairly certain he will have a very good read.
Many thanks for sharing!

Reply

sites de rencontres June 6, 2014 at 3:08 pm

Thanks in support of sharing such a good opinion, piece of
writing is nice, thats why i have read it entirely

Reply

Rohan Hulyalkar May 29, 2014 at 11:56 am

I had one query regarding the error probability (Pe).

I have a set of values:
Y=[4.0829
45.2948
60.4492
0.6844
1.6557
6.4594
5.0681
5.2660
5.2568
5.4682
4.0257
3.8263
4.0347
5.4421
4.6136
0.4129
0.1094
0.0957
5.3773
1.4608
2.8782
0.3875
0.4000
33.6456
33.4021
46.8380
74.1583
45.4767
1.5635
45.9417
10.2164
45.5156
56.0098
17.0093];
I want to plot the error probability (Pe) as a function of ‘mu’ (threshold). Can you please help me regarding the same?

Waiting to hear ASAP.

Kind regards,
Rohan

Reply

Bobbie May 22, 2014 at 4:32 am

Hi, after reading this amazing piece of writing i am as well delighted to share my
knowledge here with colleagues.

Reply

cliquez ici May 20, 2014 at 5:34 pm

What’s up, yup this paragraph is truly fastidious and I have learned lot of things from it
about blogging. thanks.

- cliquez ici
- cliquez ici
- cliquez ici
- cliquez ici
- cliquez ici
- cliquez ici

Reply

timex personal trainer heart rate monitor manual May 16, 2014 at 5:40 am

Have you ever thought about writing an ebook or guest authoring on other websites?
I have a blog based upon on the same topics you discuss and would really like to have you share some stories/information.
I know my visitors would enjoy your work. If you’re even remotely interested, feel free to send
me an e-mail.

Reply

Carmela May 13, 2014 at 5:29 pm

Many mothers will have a gift registry at various stores or even online.
No need to pay for it, just find a street and park that car.
Diaper cakes are also a great way to promote environmentalism because you can use organic cloth diapers to make your diaper
cake.

Reply

http://whju.ca/ May 8, 2014 at 2:18 am

Interesting stuff, I changed template on my site and then the serps plummeted
Will defo be returning, ’tis a great site

Reply

aled88 May 6, 2014 at 8:15 pm

Hi, mr. Krishna, is a long time since I follow his posts, so thank you for the valuable information that I found in the blog. I have a question about the code, in particular with regard to the following line :

theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))).

my doubt is regard the use of exponential term 10.^(Eb_N0_dB/10). why is written in this way?

thanks in advance for your attention.

Reply

Mounica May 3, 2014 at 12:31 am

can any1 pls help me calulate ber for the following direct sequence spread spectrum code using bpsk modulation??

clc;
clear all;
close all;
R=7;
T = [zeros(1,R), ones(1,R)];
T = T(randperm(2*R));
x=T;
[T]
z=length(x);
x(x==0)=-1;
for i=1:1:z
q((i-1)*100+1:i*100)=x(i);
end
b=length(q);
t=0.01:0.01:z;
c=2*cos(2*pi*t);
y=c.*q;
hpn = comm.PNSequence(‘Polynomial’,[3 2 0], …
‘SamplesPerFrame’, 14, ‘InitialConditions’,[0 0 1]);
x1 = step(hpn);
xw=x1′;
xw=xw(:)’;
[xw]
N=length(xw);

for i=1:1:N
m((i-1)*100+1:i*100)=xw(i);
end

h=y.*m;
figure;
plot(t,m);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘pn code modulated signal’);

figure;
plot(t,c);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘sinusoidal signal’);

figure;
plot(t,y);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘PSK modulated signal’);

r=randn(1,length(h));
k=h+r;
figure;
plot(t,k);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘noise added PSK signal’);

t1=0:0.01:.99;
r1=cos(2*pi*t1);
r2=fliplr(r1);
l=length(k)+length(r2)-1;
d1=fft(k,l);
d2=fft(r2,l);
d=d1.*d2;
p=ifft(d,l);

figure;
plot(p);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘correlated signal’);
for j=1:length(x)
q(j)=p(100*j);
if q(j)>0
n(j)=1;

else
n(j)=0;

end
end
op=n.*xw;
[op]
op(op==0)=-1;

figure;
len1=0:1:length(op)-1;
stairs(len1,op);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘demodulated signal’);

i=length(x)
for i=1:1:i
q((i-1)*100+1:i*100)=x(i);
end

figure;
ftr1=fftshift(abs(fft(q)));
plot(ftr1);

xlabel(‘frequency’);
ylabel(‘amplitude’);
title(‘signal spectrum’);

figure;
ftr=fftshift(abs(fft(h)));
plot(ftr);
xlabel(‘frequency’);
ylabel(‘amplitude’);
title(‘spreaded signal in frequency domain’);

figure;
stairs(x);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘input signal’);

figure;
stairs(xw);
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘pn seq’);

figure;
ftr2=fftshift(abs(fft(p)));
plot(ftr2);
xlabel(‘frequency’);
ylabel(‘amplitude’);
title(‘correlated signal spectrum’);

p=length(op)
for i=1:1:i
s((i-1)*100+1:i*100)=x(i);
end

figure;
ftr3=fftshift(abs(fft(s)));
plot(ftr3);
xlabel(‘frequency’);
ylabel(‘amplitude’);
title(‘signal spectrum at receiver or despreaded spectrum’);

figure;
ftr4=fftshift(abs(fft(y)));
plot(ftr4);
xlabel(‘frequency’);
ylabel(‘amplitude’);
title(‘bpsk modulated spectrum’);

Reply

William Hill Bonus May 2, 2014 at 7:33 am

Your style is very unique compared to other folks I have read stuff from.
Many thanks for posting when you’ve got the opportunity, Guess I will just book mark this
site.

Reply

georgina gee blog May 2, 2014 at 6:44 am

Link exchange is nothing else however it is only placing
the other person’s blog link on your page
at proper place and other person will also do same in favor of you.

Reply

sell structured settlement payments April 26, 2014 at 6:48 am

If the plaintiff and defendant agree to make monthly payments of $25,000 they
won’t be taxed. However, the cash you will get upfront is only enough to coiver the medical
expenses you have accumulated. A structured settlement is sort of a method of payment to protect the receiver of the funds from losing
everythinng due to mismanaging their money.

Reply

agar cepat hamil April 25, 2014 at 3:06 pm

Great blog here! Also your site loads up very fast!
What web host are you using? Can I get your affiliate
link to your host? I wish my web site loaded up as fast as
yours lol

Reply

scrabble gratuit April 25, 2014 at 2:55 pm

Google’s goal is to satisfy its search customers, so if
Google’s customers (who are also your viewers) are delighted with what they find at your website, then Google is going
to be thrilled as well. The result is too high insulin
levels or insulin spikes. scrabble gratuit Keyword terms can be utilised in your resource box to form the link back to your website.

Reply

film indonesia jaman aku yang dulu guitar chord April 24, 2014 at 2:29 pm

I’ve been surfing online greater than 3 hours lately, but I by no
means discovered any attention-grabbing article like yours.

It is lovely worth sufficient for me. In my opinion,
if all web owners and bloggers made just right content as you did, the net will be
much more helpful than ever before.

Reply

using wordpress to blog April 23, 2014 at 7:09 pm

Oh my goodness! Awesome article dude! Many thanks, However I am experiencing issues with your RSS.
I don’t understand the reason why I am unable to join it.

Is there anybody else having similar RSS problems?
Anyone who knows the answer will you kindly respond?
Thanx!!

Reply

辦公椅 April 23, 2014 at 6:12 am

It’s an amazing article designed for all the online people; they will take benefit from it I am sure.

Reply

unique wedding cake toppers April 23, 2014 at 5:55 am

hey there and thank you for your information – I have certainly picked up anything new from right here.
I did however expertise several technical issues using this site, as I experienced to reload the site many times previous to I could get it to load properly.
I had been wondering if your web host is OK?
Not that I am complaining, but slow loading instances times will sometimes affect your placement in google and can damage your quality score if advertising and marketing
with Adwords. Anyway I am adding this RSS to my e-mail and could look out for much more of your
respective exciting content. Ensure that you update this again soon.

Reply

Holika Holika April 22, 2014 at 9:58 am

I love to disseminate information that will I have accrued with the season to
help improve team efficiency.

Reply

宜蘭民宿 April 22, 2014 at 8:25 am

I have a confident analytical attention for the purpose of fine detail
and can foresee complications just before they take place.

Reply

العاب April 22, 2014 at 6:32 am

Your mode of describing the ѡhole thing in thiѕ paragraph іs гeally pleasant,
еvery oոe ϲan simply know it, Ƭhanks a lot.

Reply

Heather April 21, 2014 at 4:40 pm

Nowadays, a large number of such tools are present but all of them use different algorithms and different equipment and the results obtained from every
each one are more or less accurate. All in all the Maya College student Edition Superpack is very substantially a comprehensive suite of equipment to make expert animation and visual consequences.
“Yep, and I believe it was the biggest mistake of my life.

Reply

行銷 April 21, 2014 at 3:58 pm

It is not my first time to go to see this site, i am browsing this web page
dailly and take pleasant facts from here every day.

Reply

news server April 20, 2014 at 9:34 am

Thiis is my firrst time payy a visit at here and i amm
genuinely impressed to read all at one place.

Reply

フォリフォリ 財布 レディース April 19, 2014 at 6:05 pm

Hi this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if
you have to manually code with HTML. I’m starting a blog soon but have no coding experience so I wanted to
get guidance from someone with experience. Any help would be enormously appreciated!

Reply

hearthstone heroes cataclysm world of warcraft release date April 19, 2014 at 5:52 am

One such device STK4221 from SANYO can be simply used for different massive
power audio amplifier applications. As I burst through
the club doors, I came to a terrifying conclusion. The problem with this
type of response is that you don’t know.

Reply

Kathi April 15, 2014 at 2:15 am
how to get rid of hpv warts April 12, 2014 at 5:19 pm

Yet generating set up giving away a number time about Wisconsin, I could not can help and yet become aware of the way in which just about everyone dwelling in this kind of bright and sunny State comes with a specifically
bright be happy. Most of us have proper teeth.

Everyone’s shiny white teeth. I can realize that your just isn’t the scenario
on top of the Region of human also know as the North of most
The united kingdom generally.

Reply

ช่างกุญแจ April 9, 2014 at 8:39 am

Excellent way of explaining, and nice piece of writing to obtain information about my presentation
topic, which i am going to present in university.

Reply

Rangeet Mitra April 8, 2014 at 7:03 pm

I have sent a mail to you requesting for your free ebook. Please mail it to me.

Reply

www.jobul-tau.ro April 7, 2014 at 8:24 pm

Whats up very cool site!! Man .. Excellent .. Wonderful ..
I will bookmark your web site and take the feeds also? I am
happy to seek out so many helpful info here in the publish, we’d like work out more techniques on this regard, thanks for sharing.
. . . . .

Reply

goodwood residence April 7, 2014 at 4:16 am

Hi, I think your blog may be having web browser compatibility issues.
When I take a look at your blog in Safari, it looks fine however when opening in IE, it’s got some overlapping
issues. I simply wanted to provide you with a quick heads
up! Other than that, great blog!

Reply

Gogol Saha April 5, 2014 at 10:49 pm

I want the matlab code for probability of symbol error for BFSK modulation

Reply

karthiksharma July 4, 2013 at 11:23 pm

hai krishna

This is Karthik sharma. doing my Masters in communication..
in my final year project i implemented a MIMO-OFDM WiMAX system using matlab simulink. The SNR vs BER graph for the model is showing a straight line instead of a waterfall graph.. kindly help me .
waiting for your reply..

Regards

Reply

Krishna Sankar July 15, 2013 at 4:18 am

@karthiksharma: are you getting a zero ber in the no-noise case?

Reply

supas March 14, 2013 at 6:07 pm

Hi Krishna,
Thank you for this website

i have two question please
1- Why the WGN (n) is outside the statement (for) while in other your program (script_ber_bpsk_rayleigh_channel) is inside (for).

2- Please can you give me the equation of WGN or give me the name of reference

Reply

Krishna Sankar March 15, 2013 at 5:31 am

@supas: Replies
1/ ideally, one would want to give different noise realization for each snr point. with that in mind, having the wgn statement inside the for loop is better
2/ wgn is created using randn function

Reply

kavitha March 5, 2013 at 11:08 am

hello sir,
I want matlab codings for SOVA algorithm,could you please help me for successful matlab codings

Reply

Krishna Sankar March 13, 2013 at 6:20 am

@kavitha: SOVA is soft output viterbi alogrithm – used in turbo coding. i have not discussed turbo codes yet in the blog.

Reply

marvellous March 2, 2013 at 11:55 am

I have a doubt regarding the scaling of noise power you have put in the code..
clearly, variance= sigma^2= No/2;

hence, while writing y= x+ n
since MATLAB generates unit variance noise, we should multiply it by sigma to get our scaled noise ,
y= x+ sigma*N
i.e. y= x+ sqrt(No/2)*n,
where n is randn(1,1) or 1/sqrt(2)*[randn(1,N) + j*randn(1,N)] doesn’t matter both are unit variance,

but in your code you have multiplied n with sqrt(No) rather than sqrt(No/2) so an extra divide by sqrt(2) is needed.

#in your code
taking signal energy as unity,
No= 10^(-Eb_N0_dB(ii)/10)
sqrt(No)= 10^(-Eb_N0_dB(ii)/20);

y = s + 10^(-Eb_N0_dB(ii)/20)*n;

Please correct me if I am wrong and clear the doubt.

Reply

Krishna Sankar March 21, 2013 at 6:28 am

@marvellous: Hmm.. isn’t the code doing 1/sqrt(2) first and then sqrt(N0)? The term sqrt(N0/2) is for real and imaginary arm
http://www.dsplog.com/2012/03/25/thermal-noise-awgn/

Reply

Ravinder February 1, 2013 at 9:05 pm

Hi Krishna

I have a question regrading “sigma” the standard deviation of noise:
We know that sigma = sqrt(No/2), for complex noise. right?
But how about real noise? Is sigma = sqrt(No)?
where No is noise power spectral density.
I look forward to hear from you soon.
Many Thanks

Reply

Krishna Sankar February 5, 2013 at 5:41 am

@Ravinder: The term 1/2 comes because the noise is symmetric across +ve and -ve frequencies. Hope the post on thermal noise and awgn gives additional pointers
http://www.dsplog.com/2012/03/25/thermal-noise-awgn/

Reply

Ravinder February 5, 2013 at 1:35 pm

Thank you very much for your reply Krishna.

Reply

ruby January 27, 2013 at 4:10 am

pls can you help solve this question; Given a stationary transmitter is sending at a center frequency of 900 MHz, the receiver is
travelling at speeds of (a) 1 km/hr; (b) 10 km/hr; (c) 100 km/hr; or (d) 500 km/hr. Draw
a graph of four curves that show deviation of spectral frequencies from the center frequency
for the above four scenarios. Use a legend properly to distinguish different scenarios.
5. Suppose that a mobile node is moving at a speed of 150 km/hr in a typical urban environment
(e.g., highway). It transmits a signal to the base station at a center frequency of fc = 1 GHz
using a binary modulation at a data rate R. It is known that the typical RMS delay spread
 of multipath propagation in this scenario is around 5 s. For each of the following cases,
decide if the received signal is best described as undergoing fast/slow fading, frequency
selective fading or flat fading.
(a) The mobile node is sending at a data rate of R = 1 Mbps.
(b) The mobile node is sending at a data rate of R = 500 kbps.
(c) The mobile node is sending at a data rate of R = 50 kbps.

Reply

Krishna Sankar February 1, 2013 at 5:25 am

@ruby: wont be able to help directly, but can point you to the following wikipedia links:
http://en.wikipedia.org/wiki/Doppler_effect
http://en.wikipedia.org/wiki/Rayleigh_fading

Reply

Ozgeee December 26, 2012 at 3:47 am

Why is my comment not appeared :(

Reply

Krishna Sankar December 26, 2012 at 7:08 am

@Ozgee: There is moderation enabled. :-)

Reply

Ozgeee December 26, 2012 at 3:37 am

First of all, congratulations for this helpful and nice explanation. I’m dealing with the similar task (maybe the same) these days. I determine two waveforms, Tb and BW, then I’m trying to draw the plot of Pe versus BW. Is yours exactly the same thing that I want to do? However, in my design, there are two integrators. I couldn’t get the point that whether you used integrator in your matlab code or not. Also, if we use lowpass filter, instead of AWGN is there a change? I’m very new at digital communication, so I’m sorry for these bad questions :)

Reply

Krishna Sankar December 26, 2012 at 7:06 am

@Ozgee: Replies:
1/ This simulation is doing bit error rate vs SNR (not vs Bandwidth)
2/ This code does not have any integrator – but a typical implementation will need a matched filter
see the following example : http://www.dsplog.com/2009/05/08/ber-with-matched-filtering/
3/ Loop filter and awgn two independent aspects.

Reply

Vishnavi December 24, 2012 at 7:16 am

Hi ,I need program for BER reduction using SSPA(solid state power amplifer ) model .or else BER reduction using PTS scheme.

Reply

Krishna Sankar December 25, 2012 at 5:46 am

@Vishnavi: Sorry, I do not know the topic.

Reply

karim December 8, 2012 at 3:39 am

could u send me the matlab code .plz

Reply

Krishna Sankar December 8, 2012 at 3:49 am

@karim: the link is provided in this post.

Reply

Yamsha December 4, 2012 at 2:30 am

Hi!

You’ve calculated the BER with a message of 1exp6 bits, and the curve obtained is perfectly over the reference, but if you take less than 1exp6 (e.g. 1exp4) apears irregulats peaks on the curve.

My question is……that’s something that I have to worry? Or it’s correct the response of the curve?

Thank you very much!

Yamsha

Reply

Krishna Sankar December 4, 2012 at 6:15 am

@Yamsha: To get confidence in the simulated results, one need to get sufficient number of errors. For eg, to get a bit error rate of the order of 10^-6, one needs to send atleast 10^7 bits.

Reply

Yamsha December 5, 2012 at 1:53 am

Thanks a lot!

Thats the information that i need! :)

Yamsha

Reply

trung tong December 1, 2012 at 4:23 pm

Hi Krishna,
Can we use importance sampling to measure the BER very small (below 10^-10) ?

Reply

Krishna Sankar December 4, 2012 at 6:21 am

@trung tong: To get a BER of 10^-10, need to send atleast 10^11 bits. Do not use this code, use C model to do the simulation (will be faster)

Reply

phani November 23, 2012 at 1:51 pm

Hi Sir…
Can you Provide the matlab code for Analysis and design of OFDM-IDMA systems
it’s very urgent….!

Reply

Krishna Sankar November 27, 2012 at 5:47 am

@phani: sorry, do not know about ofdm-idma topic

Reply

Tony November 22, 2012 at 7:51 pm

Dear Mr Krishna.

Im trying to draw the same function, BPSK with AWGN, in excel.
I get a completely different graph, so i must be doing something wrong.

May i contact you by mail to send you my table?.

Thanks very much.

Reply

Krishna Sankar November 27, 2012 at 5:49 am

@Tony: In excel, make sure that you are selecting log-scale for the y-axis.

Reply

BALA MURTHY October 31, 2012 at 4:29 pm

Can you please provide the code for 2×2 MIMO with spatial diversity and different reciever combining schemes for a system using m-PPM modulation. Using gamma-gamma channel model.

Reply

Krishna Sankar November 2, 2012 at 7:03 am

@BALA MURTHY: Please check out post @
http://www.dsplog.com/category/mimo

Reply

Manoj October 31, 2012 at 3:21 am

I need this in matlab with expalnation.
Compute the error probability of a BPSK as a function of Es/NodB (in decibel)
{1; 2; 3; 4; 5; 6; 7; 8; 9; 10}.
1.What is the energy of a BPSK symbol (Es)? And the Energy per bit (Eb)?
Comment.
2.The noise variance is
sigma^2 =N0/2
hence for each value of Es/NodB you can derive the associated sigma^2 that you
need to generate your additive white gaussian noise.
3.Generate a vector x representing N=1000000 BPSK equiprobable symbols.
4.Estimate the transmitted symbol x based on the received signal y = x + n.
Show the histogram of y for Es/NodB = 1 and Es/NodB = 10 (comment the
fi gures)
5.Compute the average error probability as the number of errors over the total
number of transmitted symbols N.
6.Repeat the steps for each value of Es/NodB and plot the corresponding P(e) in
a log scale (use the function semilogy with “blue” line). Comment the results.
What is the minimum Es/NodB to guarantee a P(e) < 10^-5? In the same
gure plot ("red" line) the theoretical P(e) of a BPSK (see slides). Comment

Reply

Manoj November 1, 2012 at 5:57 pm

Dear krishna sankar sir,
could you please help me regarding the question i posted

Reply

Krishna Sankar November 2, 2012 at 7:07 am

@Manoj: The matlab code in this article should be able to address most of your queries.

Reply

Krishna Sankar November 2, 2012 at 6:43 am

@Manoj: This post (and the matlab code) on BER of BPSK in AWGN is addressing most of your queries. Good luck!

Reply

Manoj November 6, 2012 at 4:25 pm

thankyou very much sir

Reply

sai charan December 11, 2012 at 5:59 pm

books

Reply

Nada October 15, 2012 at 1:04 pm

could you please explain the relationship between the BER and the Eb/No and why we get this graph shape
looking for your reply
Nada

Reply

Krishna Sankar October 17, 2012 at 6:31 am

@Nada: The derivation is explained in this post

Reply

pawan September 16, 2012 at 5:24 pm

hey

How do you calculate the SNR if given bit error rate of 10^-3.

Secondly if now i am given a symbol like P which when converted to binary is equal 011. How do i calculate the snr if i need a symbol error rate of less than 10 ^-4 ??

thanks

Reply

Krishna Sankar September 18, 2012 at 5:45 am

@pawan: you can either use the visual information from the ber plot to find the minimum snr required to hit a given bit error rate. for eg, bpsk in awgn requires around 7dB of Eb/N0 to hit 10^-3 ber. One can also use the erfinv() function.

Reply

ebtesam jumma September 15, 2012 at 9:18 pm

can you exaplan about curve of error performance of BPSK over AWGN and Rayleigh channel?

Reply

Krishna Sankar September 18, 2012 at 5:38 am
vanness August 27, 2012 at 9:31 am

Hi, Krishna

Would like to ask how to add attenuation to the transmitted signal?
which line of code should i edit? is it from ”y = s + 10^(-Eb_N0_dB(ii)/20)*n;”
In case if attenuation = 0.3

Reply

Krishna Sankar August 29, 2012 at 5:19 am

@vanness: Well, shouldn’t it be straightforward

attn = 0.3;
y = attn*s + 10^(-Eb_N0_dB(ii)/20)*n;
:-)

Reply

phucmv August 25, 2012 at 12:12 pm

Hi Krishna,
I want to demo about DSSS spread spectrum systems by MATLAB. it’s my project
it uses modBPSK and PN
but i’m not good at matlab programming
can you help me about it ?
thankyou very very much !!
my email : phuc0605bk@gmail.com

Reply

Krishna Sankar August 29, 2012 at 5:29 am

@phucmv: sorry, wont be able to help you with the matlab programming. good luck

Reply

candy July 23, 2012 at 10:59 am

Hi Krishna,

In this post, it is very useful that you show the relationship between BER and SNR. Actually, I want to describe the relationship between BER and transmission distance for BPSK in AWGN channel. Please give some advices for this.

Thank you so much!!

Reply

Krishna Sankar July 24, 2012 at 5:40 am

@candy: To convert to a distance, one needs to know – Transmit power, Path loss, Receive noise power
The SNR, dB at the receiver is = Tx Power, dBm – Path Loss, dB – Rx Noise Power, dBm

The transmit power is chosen by the designer. The path loss depends on the square of the carrier frequency and square of the distance in free space. Check out http://en.wikipedia.org/wiki/Free-space_path_loss.
The receiver noise power depends on the bandwidth of the receiver. For eg, a receiver with a 20MHz bandwidth will have a thermal noise power of -174dBm/Hz + 10*log10(20e6) = -101dBm.
http://www.dsplog.com/2012/03/25/thermal-noise-awgn/

Hope this helps.

Reply

candy July 24, 2012 at 11:17 am

Dear Krishnan,
Thank you so much for your help!
I have another problem that I can not understand as:
I used the formula: BER = 0.5*erfc(SNR) for BPSK in AWGN channel to plot the picture which show relationship between BER and propagation distance through the relationship between SNR and distance based on free space path loss model. But I can not explain why BER can not be greater than 0.5 even the distance is increased up top very large value. I think that this result is not suitable with the fact that when BER will be increased to 1 when distance increased from 0 to infinite.

I hope you give me some advices for this.
Thanks.

Reply

Krishna Sankar July 26, 2012 at 5:27 am

@candy: well, when we flip a coin we have a 50% chance of getting the call correct. :-)

Reply

candy July 26, 2012 at 5:32 am

Thank you so much!

ANIL KUMAR July 23, 2012 at 8:08 am

Dear Krishnan,
Could you help me writing the code for this question.

Simulate 4-PAM (k = 2,M = 4). Pairs of bits are mapped into symbols s, where s belongs to the alphabet S = (3A, A,-A,-3A). Note that the input symbols are equiprobable, and there is no need to generate individual bits. Additive noise n is real AWGN process (same as in (1)). The input into the detector is r =s + n. The
detector finds the closest point in S to r. The average symbol SNR s = 5A square / 2. The bit SNR b = SNR s / 2. Simulate performance of this system for SNR b = 7, 8, 9, 10, 11 dB and find the symbol and bit error rates.

Your cooperation in this regard will highly be appreciated

Thanks
Anil

Reply

Krishna Sankar July 24, 2012 at 5:33 am

@Anil: Long back, I have written a post on symbol error rate for 4-PAM.
http://www.dsplog.com/2007/10/07/symbol-error-rate-for-pam/
Hope this helps.

Reply

megha July 19, 2012 at 3:06 pm

I want the code for IEEE project of “Error correction between convolutional codes using Chaotic switching.

Reply

Krishna Sankar July 23, 2012 at 4:41 am

@megha: what is chaotic switching? the regular convolutional code with viterbi decoder is discussed in
http://www.dsplog.com/tag/viterbi

Reply

khushi July 17, 2012 at 4:04 pm

Hello Sir
I am new here and i need your help.Please give me answers of my few questions. I will be thankful to you.:
1. ip = rand(1,N)>0.5
how it generate only +1 and -1
what is the concept of using the term>0.5

2. Eb_N0_dB = [-3:10]
how the range of Eb/No is chosen and what is the need of this?

3. for ii = 1:length(Eb_N0_dB)
what is the concept of this function?

Reply

Krishna Sankar July 18, 2012 at 6:41 am

@khushi: my replies
1. rand() generates a uniformly distributed number in the range from [0 to 1). The >0.5 allows to generate a input sequence with approximately equal probabilities for 0 and 1.
Then 2*0 – 1 = -1 and 2*1 – 1 = +1

2. This is the region where the BER for BPSK modulation changes from from very high ber (>0.1) to very low ber (<10^-4)

3. To find the ber for different Eb/N0 values

Reply

khushi July 18, 2012 at 11:41 am

Thank you very much Sir for solving my problems
One more thing I want to know that how do we know that in which range BER changes from from very high ber to very low ber.

Reply

Krishna Sankar July 20, 2012 at 6:28 am

@khushi: From the theoretical bit error rate equation

Reply

khushi July 20, 2012 at 1:51 pm

sir will u please tell me that from where I can see that equation

Zoe July 3, 2012 at 10:16 am

Hi Krishna,
Could you answer the following q’s please if you have the time? Thanks. Zoe

1. I don’t know how the following counts. Is nErr(ii) an array?
And I don’t precisely know what ‘size’ and ‘find’ functions do?
(I know ip-ipHat = 0 is no error)

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

2. In the following is the decimal version of EbNo getting multiplied with n, mean of the Gaussian noise? (of course then added with s, -1 or 1, depending on what was sent)
y = s + 10^(-Eb_N0_dB(ii)/20)*n

3. The following is confusing. Why two real and imaginary component Gausian functions added and normalized by inverse of “sqrt(2)”
Could you write the formula or equation it is derived from?

n=1/sqrt(2)*[randn(1,N) + j*randn(1,N)]

Reply

Krishna Sankar July 5, 2012 at 5:12 am

@Zoe:
1. nErr is the count of errors.
find() finds the index of elements which are different between ip and ipHat
size() counts the number of elements which are reported by find()

2. it is the Eb/N0 in linear scale applied to the noise voltage to produce the desired Eb/N0 ration

3. one can possibly send information on the two dimensions together. Hence we model as two randn() variables each with variance 1/2. Hence the normalization by 1/sqrt(2) on the voltage signal.

Reply

ebtesam June 14, 2012 at 8:07 pm

hi , iam new here i need disscision about ber performance of bpsk over awgn and rayliegh channel

Reply

Krishna Sankar June 26, 2012 at 5:55 am
Aisha June 4, 2012 at 7:11 pm

Hi dear,

how are you.I need a help from you because I have a project and there some points i don`t understand it.

It is about the square root raised cosine pulse ,we need to plot it with different roll-off factor(B=0.25,B=0.5,B=1.
After that consider a binary antipodal signaling over an ideal AWGN channel at the normalized bit rate of 1 bit second where TB =1
x(t)=+or-p(t) +w(t)
where w(t) is an additive white gausian noise ,simulate model for this system and plot the resulting BER (B=0.5)

Reply

Krishna Sankar June 11, 2012 at 5:21 am
Arinze Nwodogwu May 17, 2012 at 9:08 am

Hello Krishna Pillai,
thanks alot for the wonderful work you did here.please can i have d privilege to have your personal email address. I have something personal to email to you with respect to my undergraduate project work.Thanks.

Reply

Krishna Sankar July 2, 2012 at 5:23 am

@Arinze : Please use the email listed in http://www.dsplog.com/contact-us/

Reply

Justin April 20, 2012 at 12:50 am

hi,
how can I plot the bpsk waveform for the sequence [1 0 1 1 0 1 0] please .
Thanks.

Reply

Krishna Sankar April 23, 2012 at 5:24 am

@Justin: If you want to pulse shape with a rectangular filter,
>>os = 4
>>x = [1 0 1 1 0 1 0];
>>xp = kron(x,ones(1,os));
>>plot(xp)

Reply

Asia April 16, 2012 at 3:46 pm

Please help me with simulating BPSK with direct-sequence spreading using m-sequence .I have tried doing the spreading and the despreading as well as noise addition but the BER vs. EbN0 curve is higher!!!! than the theoretical one ,which is the same as BPSK without spreading .
the problem could be with the addition of the noise ; I did multiply the transmitted chips by 1/sqrt(N) ,where N is spreading factor ,in order to make sure that the bit power is 1 .

Here is my code:
clear
b = 10000; % number of bits or symbols

%—————– Transmitter————–
%Message signal
ip = rand(1,b)>0.5; % generating 0,1 with equal probability

%generating m-sequence
polynomial=[6 1 0];
[pnSequence,chipIndex,N]=genPNSequence(polynomial);

signal = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1 (polar)
mseq=2*pnSequence-1; % PN sequence in polar form

%spreading message signal ‘signal’ using pn sequence ‘mseq’,the processing gain
%’N';length of the PN sequence.

spreadedSig=zeros(1,N*b);
w=mseq’*signal;
spreadedSig=(1/sqrt(63))*reshape(w,1,N*b);

n = randn(1,N*b) ; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)
% Noise addition
y = spreadedSig + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

%despreading
q=reshape(y,N,b);
despreadedSig=q’*(mseq’);
despreadedSig= despreadedSig’;

% receiver – hard decision decoding
ipHat = real(despreadedSig)>0;

% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber

% plot
close all
figure
semilogy(Eb_N0_dB,theoryBer,’b.-’);
hold on
semilogy(Eb_N0_dB,simBer,’mx-’);
%axis([-3 10 10^-5 0.5])
grid on
legend(‘theory’, ‘simulation’);
xlabel(‘Eb/No, dB’);
ylabel(‘Bit Error Rate’);
title(‘Bit error probability curve for BPSK modulation’);

end of code

So please can you check what is wrong with my code??

Reply

Krishna Sankar April 17, 2012 at 4:27 am

@Asia: I couldn’t play with the code. However, if you are getting zero BER for no noise case, it points to a scaling error.

Reply

Asia April 17, 2012 at 2:23 pm

@Krishna: Hello Krishna
I have tried the no noise case and gave me zero BER . I couldn’t figure out what is the problem with the scaling ??!! Do you have any code for spreading and despreading ?
I need the correct coe for my final project on my Bachelor degree. So I should be very grateful if you can help me with this.

Reply

yahya April 12, 2012 at 4:52 pm

pleas Mr I would like to help me to find calculation BER vs SNR when using 64DAPSK modulation with DWT-OFDM in simulation MATLAB, thanks.

Reply

Krishna Sankar April 16, 2012 at 5:23 am

@yahya: Sorry, I have not tried 64DAPSK modulation

Reply

Fargo March 20, 2012 at 9:11 pm

Your article really open my eyes.
Is there anyone about calculate theory BER value of frequency selective channel in your BLOG?
Thanks,
Yushi Chen

Reply

Krishna Sankar March 21, 2012 at 4:52 am
medo March 20, 2012 at 11:56 am

i want code on CDMA transimeter and reciver with AWGN for multi user by LLR log like ratio in receiver iterative decoding ,…….i make it but without LLR can u help me plz also i put spreader but not coded as block thx

Reply

Krishna Sankar March 21, 2012 at 5:02 am

@medo: Good luck with the assignment

Reply

megha February 3, 2012 at 6:06 pm

I want the code for error correction between convolution codes using chaotic switching

Reply

Krishna Sankar February 6, 2012 at 5:12 am

@megha: Sorry, nothing handy

Reply

megha July 19, 2012 at 3:08 pm

why

Reply

stud1 February 3, 2012 at 1:31 pm

hi, this was very helpful 4 me, do you have the code for bit error rate(BER) of OOK

thanks.

Reply

Krishna Sankar February 4, 2012 at 11:16 am

@stud1: Thanks. The OOK case is very close to BFSK, you can take look at
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/

Reply

Zahra January 31, 2012 at 4:04 pm

Dear Mr. Krishna
Would you help me in my project!!!
I study this paper in IEEE for satrting my thesis in master degree. “Cross-Layer combining of adaptive Modulation and coding with truncated ARQ over wireless links” .1343909 abstract
This paper appears in: Wireless Communications, IEEE Transactions on
Issue Date: Sept. 2004
Volume: 3 Issue:5
On page(s): 1746 – 1755
but I have som misunderstand whith this paper and manye other papers like this .
The first problem is finding average SNR in mode(n).
I don’t know how can I select the average SNR in (7), (8),(15) ,…
and the second problem is ,if we select the SNR whit gama distribution in matlab for example:
gamrand(a,b)
then gama average is: ab (in gama distribution).
In fig 4, 5 ,… we have average SNR in horizontal axis and I don’t know how select from 0 to 30 db
best regards

Reply

Krishna Sankar February 8, 2012 at 5:22 am

@Zahra: Sorry, due to lack of time I wont be able to help in your project. Good luck.

Reply

Sivaganesh January 30, 2012 at 11:14 pm

Hi Krishna,
your coding’s were very useful for my simulation lab works..could you please send me the comparison of various error correcting codes for a particular modulation scheme..

Reply

Krishna Sankar February 6, 2012 at 5:15 am

@Sivaganesh: I have discussed only two error correcting codes:
a) Hamming code and decoder
http://www.dsplog.com/2009/09/29/hamming-74-code-with-hard-decision-decoding/
b) Viterbi decoder (hard and soft)
http://www.dsplog.com/tag/viterbi/

Reply

Thiyagi January 23, 2012 at 7:31 am

Thank u very much Mr.Krishna.. Could you please name a few companies recruiting in this field… I knew only the IT companies no idea about this type of companies and what will the requirements to get into those companies……

Reply

Krishna Sankar January 26, 2012 at 6:34 am

@Thiyagi: Trust that doing cursory search using google/linkedin will give you lots of pointers.
Requirement to get into any company is good knowledge of basics :)

Reply

Thiyagi January 27, 2012 at 8:41 pm

Thank You

Reply

Thiyagi January 22, 2012 at 10:53 pm

Hello Mr.Krishna

How to get rotated Pi/4 QPSK constellation? I got QPSK constellation how to get Pi/4 rotated constellation for QPSK

Reply

Krishna Sankar January 23, 2012 at 5:08 am

@Thiygai: I do not think I ‘ve discussed pi/4 QPSK. But discussion of a close cousin MSK is kept @
http://www.dsplog.com/2009/06/16/msk-transmitter-receiver/
For QPSK you can refer to
http://www.dsplog.com/2007/11/06/symbol-error-rate-for-4-qam/

Reply

abhay January 16, 2012 at 11:46 am

the above graph shows the theoritical and simulated values for bpsk from where this theoritical values comes.thnx

Reply

Krishna Sankar January 22, 2012 at 8:53 am

@abhay: The computation of the theoretical BER is discussed in this post. Idea is to find the area under the tail of the Gaussian curve.

Reply

Greg January 16, 2012 at 12:30 am

I am having problems simulating the BER vs SNR curve for the binary on-off keying modulation. My plot looks backwards. Do you have any suggests.
Here is my code
% EE474 Lab 1

clc;
clear all;
close all;

Es =1;
n=0:7;
count0 = 0;
%Simulated BER
for snr =0:7
count0 = count0+1;
error =0;
right = 0;

snr_number = 10^(snr/10);
N0 = Es/snr_number;
count = 0;
while(error0.5)
d=1;
else d=0;
end
S = d*sqrt(Es);
noise = randn*sqrt(N0/2);
D =S+noise;
if D>0
d_hat = 1;
else
d_hat =0;
end
if d == d_hat
right = right+1;
else
error = error+1;
end
end

ber_sim(count0) = error/count
end

semilogy(n,ber_sim,’o-’);
hold on;
xlabel(‘SNR’);
ylabel(‘BER (dB)’);
title(‘BER vs SNR BPSK’)

Your help is appreciated.
Greg

Reply

Krishna Sankar January 22, 2012 at 8:50 am

@Greg: Are you getting zero BER when no noise is present in the simulation?

Reply

Kabir December 31, 2011 at 6:14 pm

Dear Mr. Krishna

I’d be grateful to you if it’s possible to provide single carrier and OFDM code (Matlab) for both timing and frequency offsets with and without cyclic prefix (both for single carrier and OFDM).

Reply

Krishna Sankar January 3, 2012 at 4:37 am

@Kabir: Sorry, I do not have all those codes handy

Reply

Thiyagi December 30, 2011 at 11:25 am

Gud morning Mr.Krishna thank u for posting ur valuable comments..

for i = 1:length(SNR_dB)
y = awgn(s,i);
y_hat = real(y)>0;
[n,b]=biterr(x,y_hat);
ber=[ber,b];
end
ber2=[ber2;ber];

I checked this one no need for ‘ber2′.. I used ‘ber’ as an array to store the values of bit error ratio since biterr is an inbuilt fuction and [n,b] where ‘b’ bit error ratio for a particular snr value and we need Bit Error Ratios for all differen SNR values, for that I used variable ‘ber’ to store the values of ‘b’

Reply

Krishna Sankar January 3, 2012 at 4:38 am

@Thiyagi: Ok. So, all your issues are resolved?

Reply

Thiyagi January 22, 2012 at 6:44 pm

Yes Mr.Krishna…
I’m currently pursuing my M.Tech(Communication Engineering) in VIT.. I’m willing to work in wireless field.. I need ur guidelines to work in communication field or in signal processing so that I can prepare for my future… Pls do reply waiting for ur precious reply.. Thank You

Reply

Krishna Sankar January 23, 2012 at 5:13 am

@Thiyagi: All the best for your studies. With out being specific, I believe having the following knowledge will help you in good stead when trying to chart out a career in wireless communication/signal processing :
a) Understanding of RF architecture, RF impairments and it’s effect on the system performance
b) Phase/frequency syncrhronization
c) Channel effects – channel estimation/tracking
d) Channel coding
e) Multi user communication … to name a few…

Reply

fateme May 13, 2012 at 8:35 pm

hi,i need to have m file of each modulation and the figures of error in matalb without using the order of modulation that are in matlab.
can you help me?
thankyou

Reply

Krishna Sankar May 15, 2012 at 5:49 am
vidhya December 28, 2011 at 11:37 am

hai,
i am new in working with OFDM , so can anyone help me with simulink model of OFDM, please

Reply

Krishna Sankar December 29, 2011 at 5:27 am

@vidhya: I don’t have the simulink model, but hopefully the post on BER for BPSK over OFDM helps
http://www.dsplog.com/2008/06/10/ofdm-bpsk-bit-error/

Reply

Thiyagi December 25, 2011 at 9:50 pm

Hello Mr.Krishna Pillai I tried to plot the BER for BPSK using the following code but didn’t get correctly..Could you please kindly correct me what went wrong..
clc
clear all
close all
ber=[];
x= randint(1,200);
y= [2];
k= log2(y);
z= reshape(x,length(x)/k,k);
d=bi2de(z);
M=[2];
s=pskmod(d,M);%Psk modulation

scatterplot(s);
snr=[-3:35];
ber1=[];
for i=snr;
p=awgn(s,i);
q=pskdemod(p,M);%psk demodulation
z1=de2bi(q);
d1=reshape(z1,1,length(x));
[r,b3]=biterr(x,d1);
ber1=[ber1,b3];
end

p;
ber=[ber;ber1];
scatterplot(p);
figure()
plot(snr,ber)

Reply

Krishna Sankar December 28, 2011 at 5:41 am

@Thiyagi: If you dont add noise, are you getting zero bit error rate?

Reply

Thiyagi December 29, 2011 at 11:50 am

Yes mr.Krishna i’m getting bit error rate as zero without adding noise i.e not used ‘awgn’ function to add noise

Reply

Thiyagi December 29, 2011 at 11:59 am

Mr.Krishna for the below code i’m achieving same BER at less SNR comparing to the theoretical value, since i used AWGN inbuilt function to add noise..Whether this approach is correct? With the program given in this website it works good, from this program I tried with my logic just want to know whether the below logic is correct..Thank u
clc
close all;
clear all;
ber2=[];
N = 10^6; % number of bits or symbols
x = randint(1,N);

for i=1:length(x)
y1(i)=1; y11(i)=-1;

if x(i)==1
s(i)=y1(i);
else
if x(i)==0
s(i)=y11(i);
end
end
end
s;
scatterplot(s);
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)];%AWGN
ber=[];
SNR_dB = [-3:35];
snr=10.^((SNR_dB)/10);
for i = 1:length(SNR_dB)
y = awgn(s,i);
y_hat = real(y)>0;
[n,b]=biterr(x,y_hat);
ber=[ber,b];
end
ber2=[ber2;ber];
figure()
form_ber = 0.5*erfc(sqrt(snr)); % theoretical ber
semilogy(SNR_dB,form_ber,’g.-’);
hold on
semilogy(SNR_dB,ber2,’bs-’)
legend(‘theoretical BER’,'practical BER’)
axis([-3 10 10^-5 1])
grid on

Reply

Krishna Sankar December 30, 2011 at 4:53 am

@Thiyagi: The code looks ok. You can check couple of points:
a) awgn : whether the noise power is as expected. Maybe you can try with ‘measured’ option.
From Mathworks http://www.mathworks.in/help/toolbox/comm/ref/awgn.html
“y = awgn(x,snr,’measured’) is the same as y = awgn(x,snr), except that awgn measures the power of x before adding noise.”

b) Counting the number of error. That piece of code looks funny. Did not understand the need for ber and ber2.
Should be easy for you to figure out.

Krishna Sankar December 30, 2011 at 4:53 am

@Thiyagi : ok, good

Reply

sarah December 21, 2011 at 2:12 am

hai,
i would like to know why in y = s + 10^(-Eb_N0_dB(ii)/20) we use a negative sign her e for eb no.
Thanks in advance

Reply

Krishna Sankar January 3, 2012 at 4:44 am

@sarah: The -ve sign is to scale down the noise signal with respect to desired signal

Reply

Talib December 20, 2011 at 11:06 pm

1.10^(-Eb_N0_dB(ii)/20)*n
2.10^(-Eb_N0_dB(ii)/10)

i want to answer the confusion of /20 why not by /10?

In fact sir Krishna Pillai want to make noise variance equal to 1 or 0dB.
you can check by command max((10^(-Eb_N0_dB(ii)/20)*n))= 1.01 where as
max((10^(-Eb_N0_dB(ii)/10)*n))= 0.3251 so its clear scaling…..remember before these commands i just removed the complex part i.e n = 1/sqrt(2)*[randn(1,N)]; for my easyness.

I also noticed that this scaling change for system to system e.g for non coherent 4FSK -it becomes like (10^(-sqrt(2)*Es_2N0_dB(ii)/20))*n becoz in 4FSK i need variance 0.5.so i scaled it to 0.5 by just multiplying by sqrt(2)

Reply

Krishna Sankar January 3, 2012 at 4:48 am

@Talib: Replies:
1. The /20 is to scale the noise voltage signal. Using max is not a good idea :)
2. I think for FSK coherent demodulation, which uses 0/1 modulation has 3dB poorer BERwhen compared to BPSK
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/

Reply

Emmanuel December 7, 2011 at 12:32 pm

Do you have code on how to generate a NRZ signal?

And do you have code on how to generate the eye diagram. Thanks.

Reply

Krishna Sankar December 8, 2011 at 5:49 am
Guhan May 19, 2011 at 6:44 pm

Hi krishna,

Could i have codings with different modulations with different subcarriers for any one user in MIMO OFDM system .output shouild be throughput versus time or ber and time.please help me sir.Thank you in advance

Reply

Krishna Sankar May 23, 2011 at 2:34 am

@Guhan: Yes, you can have independent modulation on different subcarriers.

Reply

Marcos Amaral May 17, 2011 at 2:51 am

Hello Krishna Sankar,

I am doing some research on chaotic carriers and I was planing to make this BER for comparison.
Your post save me a lot of time to focus on the real subject of my work.
Thank you very much for the help!

Regards from Brazil
Marcos Amaral

Reply

Krishna Sankar May 23, 2011 at 3:05 am

@Marcos: Thanks.

Reply

Nikhil May 14, 2011 at 2:16 am

hi krishna,
please send the matlab codes(whatever u have about that paper) for below linked paper, I am doing my project on that paper. Please help me. This is very urgent., Please click on below mentioned web address.
http://dspace.mit.edu/openaccess-disseminate/1721.1/52384

Reply

Krishna Sankar May 24, 2011 at 5:16 am

@Nikhil: Sorry, I have not looked into that paper.

Reply

moyeen May 6, 2011 at 1:48 pm

Hi Krishna,

I am working on different modulation technique. I am badly needed BER code of QPSK, (QAM 16,64)with AWGN channel.I have to submit my paper on 30may2011.

please send me code , this very helpful for me.

moyeen

Reply

Krishna Sankar May 24, 2011 at 5:32 am

@moyeen: You can refer to the post on BER for 16QAM with Gray coding
http://www.dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

Reply

Moyeen May 5, 2011 at 10:03 am

Dear krishna
impressive works! hay, can you provide me simulation codes for BPSK, QPSK, 16QAM & 64QAM with AWGN channel in OFDMA modulation? these would be very much helpful for my thesis. thank you.
Moyeen

Reply

Krishna Sankar May 24, 2011 at 5:34 am
Sara December 3, 2010 at 9:12 pm

Hello Krishna,
I have a question.. I am hoping to design a OFDM communication system…
If you were to design an OFDM communication system.. what and where would u start from?
Regards
Sara

Reply

Krishna Sankar May 26, 2011 at 6:04 am

@Sara: You should know your available bandwidth, then chose your subcarrier spacing and so on

Reply

Elayan November 2, 2010 at 8:18 pm

Hi Krishna,

what about 8-PSK ?
is it the same to 16-PSK and just change M=8 only?
or there is other things that i should to change ?
becouse when i changed M to 8 i got an output and no errors
pls answer me it’s very importanat
thanks alot man

Reply

Krishna Sankar November 15, 2010 at 2:12 am

@Elayan: Yes, I guess changing M to 8 should suffice.

Reply

ahmed November 1, 2010 at 12:37 pm

hi
i m doing graduation we have a project in which we have to design the communication sysem in which data+modulation(bpsk and 8-psk)+awgn then threshold detector and then we had to compute bit error rate.. can you help me in this…..

Reply

Krishna Sankar November 15, 2010 at 2:14 am

@Ahmed:
For 8 PSK case, you may use the article on 16PSK as a reference
[symbol error rate] http://www.dsplog.com/2008/03/18/symbol-error-rate-for-16psk/
[bit error rate] http://www.dsplog.com/2008/05/18/bit-error-rate-for-16psk-modulation-using-gray-mapping/

Reply

hamdirajeh October 14, 2010 at 12:03 am

its very useful thanx , do u know how can i get the simulink for this code ,please?

Reply

Krishna Sankar November 17, 2010 at 5:32 am

@hamdirajeh: Sorry, I do not have simulink code

Reply

jansi September 3, 2010 at 6:47 pm

dear krishna,
i need to simulate BPSK modulation to analyse the bit error rate in AWGN channel and reyleigh fading channel for different SNR.the carrier frequency should be 20MHz.if u hav matlab codes for dis,help me.m running out of time.
xpecting fruitful reply.

Reply

Krishna Sankar September 6, 2010 at 5:15 am
avdhut August 26, 2010 at 9:06 pm

hey…
will u plz giv code for gmsk…

Reply

Krishna Sankar September 1, 2010 at 7:04 am
weather July 30, 2010 at 8:52 am

Thanks for your detailed post!
But I have question about the comment of this line in your codes
s = 2*m-1; % BPSK modulation 0 -> -1; 1 -> 0
I think maybe you want to change original 0 to -1, but 1 should be no change, is it?

Reply

Krishna Sankar August 2, 2010 at 5:46 am

@weather: Thanks for noticing the typo in the comment. I corrected it.

Reply

Ajith July 24, 2010 at 4:46 pm

Oops i am sorry if this is a total blunder.. In digital modulation techniques we modulate a sine or a cos wave using bits and transmit them as sine or cos waves.. But in this code for BPSK modulation I never found the usage of such things.. could you please clarify my doubts in simple words… Regards Ajith

Reply

Krishna Sankar July 25, 2010 at 4:32 am

@Ajith: No, its not a blunder at all, tt’s a genuine query. There are two aspects to the reply.
a) In the case of baseband transmissions, we send the information on pulses and in the most simplest case, we send out rectangular pulses of varying amplitude to convey the information (or we can do some better pulse shaping to reduce the out of band emissions, while not introducing ISI)
b) In the case of pass band transmissions, we do the pulse shaping, then upconvert to a carrier and then transmit.

In both (a) and (b), for computing BER, the results which we get even if we do not simulate pulse shaping + up conversion is same as the one without it (assuming, we undo the operations optimally). Hence did not put those in place.

Further, I have written a post doing BER computation with rectangular pulse shaping with matched filtering
http://www.dsplog.com/2009/05/08/ber-with-matched-filtering/

Reply

prashant goad July 20, 2010 at 3:00 pm

hey krushna
That really helpful for me.
but i need it’s paper too. can u send it to me plzzz

Reply

Krishna Sankar July 21, 2010 at 6:00 am

@prashant: I referred the text book Digital Communication by Proakis

Reply

Ayesha313 July 18, 2010 at 3:47 pm

hello sir
can you please guide me,how can i plot BER error rate of uncoded and coded BPSK
i know the formula of BER for Uncoded BPSK ,i have plotted it,but I am really cunfused about the Coded Bpsk,I am using BCH codes which are block codes
Waiting for your reply

Reply

Krishna Sankar July 23, 2010 at 7:07 am
Ayesha313 July 27, 2010 at 8:58 pm

Thanks alot sir for your precious time and guidance

Reply

rama krishna June 25, 2010 at 3:43 pm

hello sir …
in BPSK constallation we map bit 1 to sqrt(Eb) and 0 to -sqrt(Eb). these are real points then why to add complex noise …we can directly add real noise of unit variance as follows…
N = 10^6 % number of bits or symbols
rand(‘state’,100); % initializing the rand() function
randn(‘state’,200); % initializing the randn() function

% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0
n = randn(1,N) ; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)
% Noise addition
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

% receiver – hard decision decoding
ipHat = real(y)>0;

% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);

end

or we can use awgn function to pass through awgn channel which will add real noise if data is real and will add complex noise if data is complex… if i proceed in that way the performance is not matching with the theoritical analasys… can u explain me clearly why should we add complex noise…
expecting early reply….
Thanking u sir

Reply

Krishna Sankar June 28, 2010 at 6:13 am

@rama krishna: Adding complex noise does not affect the end result (as we are ignoring the imaginary part at the receiver). However, just make sure that scaling is correct. You should multiply factor of 1/sqrt(2) to the noise term which you have defined.

Reply

chandra April 27, 2010 at 6:02 pm

Hi sir,
I want some programmes on DAPSK(differential amplitude phase shift keying) in OFDM systems.Is there any matlab codes in DAPSK.Please reply me as soon as possible.
Thanks,
regards,
chandra

Reply

Krishna Sankar April 28, 2010 at 5:49 am

@chandra: Sorry, no posts on DAPSK. The closest which I have discussed for ASK is the 4-PAM case
http://www.dsplog.com/2007/10/07/symbol-error-rate-for-pam/
Hope this helps

Reply

STIVE CHLEF April 24, 2010 at 12:37 am

Hi Krishna Pillai ..
I whant to simulate BER for BPSK but for 5 or 6 user not for 1 user
what is the changement applicated in this programme.

Reply

Krishna Sankar April 27, 2010 at 5:22 am

@STIVE CHLEF: Well, if you have 5/6 users, how are you planning to distinguish them at the receiver?

Reply

hakar April 18, 2010 at 6:52 pm

beatiful work krishna, i wonder if you have the same simulation for QPSK in matlab…thanks

Reply

eca April 13, 2010 at 9:08 pm

dear sir Krishna Sankar
I am very happy to find your blog … and found what I was looking for … I am a student majoring in telecommunications engineering and was doing the final tasks of rain attenuation, said supervisors told to discover how much value other than tresshold BER for MQAM rmodulasi … I want to ask how can I download the book John Proakis as an accurate reference book saya.Mohon bantuanya final … and also how the graph of the BER curve modulation 16…………

Reply

Krishna Sankar April 14, 2010 at 5:01 am

@eca: You can try purchasing Digital Communications by Proakis

Reply

fizzle April 8, 2010 at 2:03 pm

pls i need a matlab program for signal to noise ratio in a wireless communications system.. how do i do the write up for the matlab program??

Reply

Krishna Sankar April 13, 2010 at 6:18 am

@fizzle: Well, if you divide signal power by noise power, the resultant is signal to noise ratio :)

Reply

vj1892 March 29, 2010 at 9:31 pm

your kind guidance on MATLAB has been really a great help for MATLAB starters. hope u will continue in future too.

Reply

Krishna Sankar March 30, 2010 at 4:12 am

@vj1892: Thanks

Reply

amit March 23, 2010 at 11:43 pm

Hi,
Can anyone help me in my project!!!
i Have read here that there is no difference between BER vs SNR in case of BPSK and OFDM using BPSK.
But my project guide has told me to mathematically prove that BER vs SNR is better for OFDM using BPSK than simple BPSK.
Suppose there is N no. of subcarrier.Then for each subcarrier there will be BER.But if i want to calculate the total BER for n no. of sub carrier then how the BER of indivisual subcarriers are related???

Reply

Krishna Sankar March 28, 2010 at 1:51 pm

@amit: In AWGN there is no difference between using BER for BPSK and BER for BPSK using OFDM.

Reply

Ananya March 21, 2010 at 6:28 pm

hello sir,
m doing ma project on ber calculation using matlab simulation for ofdm transmission for multipath wireless communication so please if u cud help me out in knowing which book wud b d best 2 go through….where i wud b getting much of d information regarding d basics of ofdm , transmission n reception of signls using ofdm, n n… ber calculation n its various graphs hw 2 plot dm n al….
please do help me out sir in dis ……m very confused abt dis…..

Reply

Krishna Sankar March 28, 2010 at 1:55 pm
rekha March 4, 2010 at 6:34 pm

hello sir,
please give us an idea how to analyse matlab code for ofdm-awgn channel with that of theory. what are the pilots and why are they used?

Reply

Krishna Sankar March 30, 2010 at 4:33 am

@rekha: The BER performance of OFDM in AWGN is comparable to the no OFDM case. http://www.dsplog.com/2008/06/10/ofdm-bpsk-bit-error/

Reply

DaMarco February 27, 2010 at 3:35 pm

Hi There,

I need to design and develop a simulation platform in C/C++ to simulate the performance for BPSK- and 8PSK modulation through an AWGN channel and evaluate the biterror rate (BER) performance for BPSK and 8PSK in the range Eb/N0 2 [−4, 8] dB.Can you help me with any suggestion or source code.

Reply

Krishna Sankar March 30, 2010 at 5:00 am

@DaMarco: You can use the Matlab model provided in this post as a reference for the C code

Reply

gurinder February 27, 2010 at 11:28 am

respected sir
please can u help me in providing matlab code for rs codes using interleaver &qam in awgn channel
i will be thankful to u

Reply

Krishna Sankar March 30, 2010 at 5:19 am

@gurinder: I have not discussed ReedSolomon codes in dsplog.com yet. Hope to do so

Reply

anne na February 4, 2010 at 2:24 pm

hi,

I would like to demodulate QPSK but using soft decision. can you help me or guide me how I want to do this? I try the matlab function using

demodh= modem.pskdemod(ht, ‘outputType’, ‘bit’,'DecisionType’, ‘LLR’, ‘NoiseVariance’, sigma);
dec_inputt=demodulate(demodh,rt);

but the bit that I’m receive sort like it have inverse sign.
for example: if I transmit bit : 1; 0; 1 ,
I received : -10.8; +9.7; -11.2.
I’m expecting that : +10.8;-9.7;+11.2.

Or is it LLR gives this inverse sign? TQ so much if you can help me.

Reply

Krishna Sankar April 4, 2010 at 4:24 am

@anne na: Why are you using soft decision, unless you have some decoder like Viterbi following your demapper. Anyhow, I have discussed about softbit for 16QAM @ http://www.dsplog.com/2009/07/05/softbit-16qam/

Reply

anis January 28, 2010 at 4:04 pm

Hi there,
i just wondering why we need to initialize the rand and randn function?

Reply

Krishna Sankar April 4, 2010 at 4:50 am

@anis: If we initialize, we can ensure that the same random numbers are generated in any run

Reply

kishore January 25, 2010 at 9:07 pm

Hi krishna!

I need matlab code to obtain BER vs SNR curve for binary on-off keying.
also ,code for generating SER vs SNR curve for 3ASK modulation

Reply

Amjad January 10, 2010 at 12:47 pm

Dear Krishna,

I already ask this question please. reply
Can you little bit tell me how to simulate the Uncoded BER and ergodic capacity for webb channel using QPPM modulation.

Reply

Amjad January 10, 2010 at 7:06 am

Dear Krishna,

Can you little bit tell me how to simulate the Uncoded BER and ergodic capacity for webb channel using QPPM modulation.

Reply

Anvesh January 6, 2010 at 7:49 pm

haiiiiiii
i need Matlab code for digital modulation techniques.
plz give reply to me….plz

Reply

abhishek January 4, 2010 at 8:00 pm

please give help about matlab code in optimization for co channel and adjacent channel interference using ANN

Reply

Winnie December 31, 2009 at 8:42 am

Hi Krishna,
I know the BER of BPSK is 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))),
if I put channel coding before the modulation,and the code rate is R,
then if the BER equals 0.5*erfc(sqrt(R*10.^(Eb_N0_dB/10)))?
then BER with code rate 1/2 is higher than 3/4,but acturally ,it should be
lower. where is my mistake ?

Hoping for your help, thank you

Student

Reply

Mitoo2007 December 27, 2009 at 3:10 am

please can u help me in this project ::::–

2) final report(OFDM):

* genearte large no of bits using randint

* modulate the data once with bpsk & then 16-QAM

* bpsk mod is 2*data-1

* after modulation u should loop on the data with step of 64′s

each time calculating their ifft

* add the noise to each 64

* if u remeber how to add noise then do it as u know,
else use awgn

sigandnoise=awgn(signal, SNR in dB , ‘measured’ )

* do fft with steps of 64′s , the same groups of symbols that were ifft’ed

* demodulate the data ( if bpsk then bits= recdata > 0)

*calculate ber using
ber=sum(xor( transmitted bits , received bits ) )

* the whole program should be done in a large loop that loops over

SNR -5 -> 15

* in case of fading
multiply with channel before ifft then divide after ifft

* multiplication is done using (.*) not just (*)

Reply

adah December 21, 2009 at 4:36 am

dear krishna…

From my past question, actually i got my result and understand..but..i have a problem with my coding…can you help me please…
My coding…
%directional antenna
d=100;
Pt=100:100:1000;
theta10=10*pi/180;
v=int(‘cos(x)*sin(x)’,0,pi/2);
x=int(v,’x',0,2*pi);
gt10=(4*pi)*cos(theta10)/double(x);
grd=180*pi/180;
c=3e8;
f=2.4e9;
L=1;
lamda=c/f;
Pr10=(Pt.*gt10.*grd)./(((4.*pi.*d)./lamda).^2)*L;

%power noise
k=1.38e-23; %k=Boltzman’s constant
t=300; %t=noise temperature in Kelvin
b=5e6; %b=bandwidth
Pn=k*t*b;

%directional antenna
snr10=Pr10/Pn;

Rb=54e6;
ebno10=snr10/Rb;

ebno101=10.*log10(ebno10);

N = 10^6; % number of bits or symbols
rand(‘state’,100); % initializing the rand() function
randn(‘state’,200); % initializing the randn() function

% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance
% Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
% k=1:1:10;
%
% for ii = 1:length(k)
% % Noise addition
% yomni = s + 10.^(-k(ii)./20)*n; % additive white gaussian noise
%
% % receiver – hard decision decoding
% ipHatomni = real(yomni)>0;
%
% % counting the errors
% nErromni(ii) = size(find([ip- ipHatomni]),2);
%
% end

for ii = 1:length(ebno101)
% Noise addition
y10 = s + 10.^(-ebno101(ii)./20)*n; % additive white gaussian noise

% receiver – hard decision decoding
ipHat10 = real(y10)>0;

% counting the errors
nErr10(ii) = size(find([ip- ipHat10]),2);

end

simBer10 = nErr10./N;
k1=1:1:10

figure
%semilogy(k,simBeromni,k1,simBer10)
semilogy(k1,simBer10)
grid on
legend(‘theta=10′)
xlabel(‘Eb/No, dB’);
ylabel(‘Bit Error Rate’);
title(‘Bit error probability curve for BPSK modulation in simulation’);

when i changed the Pt=10:10:100; actually i got the result..can you help me pliz….

thanks a lot…

Reply

Krishna Sankar December 23, 2009 at 5:47 am

@adah: what is the problem which you are seeing?

Reply

adah December 30, 2009 at 7:12 am

dear krishna…

In theory, when i applied my SNR into your coding, i got the result.
But, when i applied my SNR into your coding for simulation, i got the problem. I think that problem occurred at SNR or BER. But i dont know where my coding is problem? Can you help me pliz…
Thanks a lot..

Reply

waheed December 17, 2009 at 6:23 pm

Hello friends: i am working on MAP , ML decoding for convolutional codes..is there any one who too work on similar field ..?

Reply

Krishna Sankar December 23, 2009 at 5:29 am

@waheed: For the Viterbi way of ML decoding, you may look at
http://www.dsplog.com/tag/viterbi

Reply

mouhamed December 16, 2009 at 10:04 pm

i want matlab programs for ‘BER MIMO’,thank u,please help me

Reply

Krishna Sankar December 23, 2009 at 5:25 am

@mouhamed: Please look at http://www.dsplog.com/tag/mimo

Reply

rama krishna December 14, 2009 at 11:29 am

i am doing simualtion to find the ber of bpsk modulation in pass band case.could you help me.

Reply

Krishna Sankar December 22, 2009 at 5:39 am

@rama: Please ask queries. I will try to answer to the best of my knowledge.

Reply

adah December 10, 2009 at 5:41 am

Hi Krishna,

Actually, im studying about your coding for BER vs SNR for BPSK modulation. For simulation, when i changed the value for EbNodB = [-3:10] to [1:10], i cant get the result. why this problem happened?

Reply

Krishna Sankar December 10, 2009 at 10:12 am

@adah: What is the error which you are getting?

Reply

fatima December 7, 2009 at 1:20 am

Hi Krishna
I need to Simulink Probability of error for binary symmetric channel if you don’t mind.

Reply

Krishna Sankar December 7, 2009 at 5:33 am

@fatima: I believe it should be reasonably straightforward to modify the gaussian channel used in this post to a binary symmetric channel. good luck.

Reply

shadat December 6, 2009 at 2:09 pm

hi krisna,
i hope you are fine.plz could you send me BPSK,QPSK,16QAM,64QAM modulation and demodulation simulation in matlab and simulation of adaptive modulation of convolutionaly coded for BPSK,QPSK,16QAM,64QAM?please help me.

Reply

Krishna Sankar December 7, 2009 at 5:27 am
Krishna Sankar December 7, 2009 at 5:27 am
rai December 3, 2009 at 9:10 am

is erfc equal Q function?

Reply

Krishna Sankar December 7, 2009 at 5:09 am

@rai: No, erfc is not equal to Q function, but both are related.
http://en.wikipedia.org/wiki/Q-function

Reply

alok joshi November 27, 2009 at 7:48 pm

hi sir
i have problem in BPSK with RS codes…..when i/p is given to pskmod function it says that “does not support complex airthmatic”.however i/p given is in 1 0 form

Reply

Krishna Sankar December 7, 2009 at 4:42 am

@alok joshi: Sorry, I do not have the pskmod() function.

Reply

Obinna O November 26, 2009 at 1:09 am

Please guys I am having trouble writing a code for non coherent detection, I am required as part of my project to Assume Rayleigh fading channel with BPSK modulation. Using MAT-LAB plot bit error probability (BEP) under non-coherent de-tection. Your ¯gures should include plots from both analysis and simulation.Use average SNR (complex) from -5 to 20 dB.

Thanks a lot, i will be very grate ful to get help from you guys.

Reply

Krishna Sankar December 7, 2009 at 4:38 am

@Obinna O: Hope you have finished the project by now. Hope this post might be of help
http://www.dsplog.com/2008/08/10/ber-bpsk-rayleigh-channel/

Reply

Hamid November 25, 2009 at 4:37 pm

hi

Why you are using 10^(-Eb_No_db(ii)/20) the minus sign in this formula because for voltage scaling it should be 10^(Eb_No_db(ii)/20).

Reply

Krishna Sankar December 7, 2009 at 4:34 am

@Hamid: The negative sign came as I am scaling the noise voltage. I am keeping the signal swing the same and reducing the swing of noise voltage to simulate various Eb/N0 values.

Reply

Faisal November 11, 2009 at 2:20 am

I am working on an adaptive modulation model on Simulink. For that first I am trying to get probability of error rate vs snr of different modulation techniques. On modelling 16 QAM modem I have problem plotting its graph by getting bit err rate from simulink model and performing graph plotting on matlab. following is the code im using in matlab..

clear; clf;
M=16; % for simulink
snr=0:10;
err_vec=[];

for i=1:length(snr)
EbNo=snr(i);
sim(‘QAM_16′);
err_vec(i)=bit_err_rate(1);
end;
semilogy(EbNo,err_vec,’b-*’);
grid on

please guide what is the error in this code… thanks

Reply

Krishna Sankar November 13, 2009 at 5:34 am

@Faisal: For BPSK,
Eb_N0_dB = [-3:10];
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
close all; figure;
semilogy(Eb_N0_dB,theoryBer,’b.-’);

Reply

Jatin Chakravarti November 10, 2009 at 11:18 pm

Hi…
I need to Simulink Probability of error for PSK, 16QAM & MFSK. but don’t know how to simulink the equation: Pe=0.5*erfc(sqrt(snr)).
I tried to call the fuction from Matlab using Embedded Function Block in Simulink. But, the program din’t work. Can u suggest me a Block for finding Pe or a Program to call from .m file..?

Reply

Krishna Sankar November 13, 2009 at 5:31 am

@Jatin: Does this help?
Eb_N0_dB = [-3:10];
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
close all; figure;
semilogy(Eb_N0_dB,theoryBer,’b.-’);

Reply

student November 10, 2009 at 9:03 pm

Hi Krishna,

I was working on a IEEE paper titled”Xiaodi Zhang and N.C. Beaulieu, “A Closed-Form BER Expression for BPSK Using MRC in Correlated CCI and Rayleigh Fading,” IEEE Trans. Communications, vol. 55, no. 12, pp. 2249-2252, Dec. 2007.”.
Since you have also worked on similar field, I hope u can help me..

I was stuck with re creating the 1st fig in the paper.
SO, can you please look into it and help me out..

Thanks,
Student

Reply

Krishna Sankar November 13, 2009 at 5:29 am

@student: Sorry, due to time constraints, may I pass that opportunity. Good luck.

Reply

Egerue Nnamdi November 10, 2009 at 3:42 pm

Hi krishna
Pls in essence how and where do we set the different values for EbNo/ or S/N or SNR to achieve different BER plots using your simulation example. Pls i will appreciate ur reply.

Thanks

Reply

Egerue Nnamdi November 9, 2009 at 3:09 am

Hi krishna
Pls in essence how and where do we set the different values for EbNo/ or S/N or SNR to achieve different BER plots using your simulation example. Pls i will appreciate ur reply.

Thanks

Reply

Krishna Sankar November 12, 2009 at 5:39 am

@Egerue: Change Eb_N0_dB

Reply

Egerue Nnamdi November 9, 2009 at 2:29 am

Hi Krishna.
Thank you very much. God will bless you. Below is the answer you gave me for my concern on this formular 10^(-Eb_N0_dB(ii)/20)*n
“Do not change the division factor. Rather change the value of Eb_N0_dB. The division by 20 is required to convert dB into voltage”.
Please give me more direction, by giving me an example of what you mean by changing the VALUE of Eb_No_dB. or how do we get the value
Am thinking is Eb_No_dB =[0:10], [0:20], [0:30] and so on, but am not very sure. Pls, you are indeed a very good teacher, help me out

Thanks, you are really very helpful, you must really reap the fruit of your efforts.
NNAMDI

Reply

Egerue Nnamdi November 8, 2009 at 8:00 pm

Hi Krishna.
Thank you very much. God will bless you. Below is the answer you gave me for my concern on this formular 10^(-Eb_N0_dB(ii)/20)*n
“Do not change the division factor. Rather change the value of Eb_N0_dB. The division by 20 is required to convert dB into voltage”.
Please give me more direction, by giving me an example of what you mean by changing the VALUE of Eb_No_dB.
Am thinking is Eb_No_dB =[0:10], [0:20], [0:30] and so on, but am not very sure. Pls, you are indeed a very good teacher, help me out

Thanks, you are really very helpful, you must really reap the fruit of your efforts.
NNAMDI

Reply

Krishna Sankar November 12, 2009 at 5:33 am

@Egerue:
You are right.
Eb_No_dB =[0:10], –> 0 to 10dB in steps of 1dB
Eb_No_dB =[0:20], –> 0 to 20dB in steps of 1dB
Eb_No_dB =[0:30], –> 0 to 30dB in steps of 1dB

Reply

Egerue Nnamdi November 4, 2009 at 2:19 pm

Hi krishna, I have actually read the answers given to you by the concerns generated by the formula below
10^(-Eb_N0_dB(ii)/20)*n
for further clarification, i have actually divided by 18,16,14,12——3 to get different plots that actually decreases down the graph . Want to know if is how one can plot for BER with variable noise in the channel. I will appreciate if you reply me soon. Thanks

Reply

Egerue Nnamdi November 2, 2009 at 10:26 pm

Hi krishna, I have actually read the answers given to you by the concerns generated by the formula below
10^(-Eb_N0_dB(ii)/20)*n
for further clarification, i have actually divided by 18,16,14,12——3 to get different plots that actually decreases down the graph . Want to know if is how one can plot for BER with variable noise in the channel. I will appreciate if you reply me soon. Thanks

Reply

Krishna Sankar November 8, 2009 at 8:39 am

@Egerue: Do not change the division factor. Rather change the value of Eb_N0_dB. The division by 20 is required to convert dB into voltage.

Reply

3mor October 25, 2009 at 2:59 pm

Hi Krishna,

thanx a lot for your website

i have a simple question:

what about the unequally probable, e.g. when P(s0)=0.25 & P(s1)=0.75 ??

Reply

Krishna Sankar October 27, 2009 at 5:45 am

@3mor: If the probabilities are un equal, we would want to shift the threshold for making the decision. The chapter 5.1.3 Digital Communications by John Proakis discuss that case.

Reply

christine October 13, 2009 at 11:21 am

Thank you for this website ,it is awesome
could you help me to know what is the role of the following

rand(‘state’,100); % initializing the rand() function
randn(‘state’,200); % initializing the randn() function
thank you

Reply

Krishna Sankar October 15, 2009 at 5:22 am

@christine: The random numbers generated by the program can be initialized to enable us to run multiple simulations with the ‘exact same’ random numbers ;) . Setting the state of the rand() or randn() enables one to do so.
Use >>help rand or >> help randn to get more information.

Reply

Ajay Pratap Singh October 8, 2009 at 2:07 pm

This Krishna Pillai guy is a great help and his website undoubtedly very good resource on communication system topic. I got necessary informations about Vitervi Algorithm, Hard and soft decision.

Ajay Pratap Singh apts

Reply

Krishna Sankar October 12, 2009 at 5:27 am

@Ajay: Thanks for the nice words.

Reply

najat October 8, 2009 at 12:44 am

Dear Krishna:
I knew that OFDM technique, improve the BER performance in frequency selective fading channel, Can you help me in writing code using matlab program show that , I have probem in how write code for frequence selective fading.
Thank you .

Reply

ahmed October 8, 2009 at 12:42 am

I knew that OFDM technique, improve the BER performance in frequency selective fading channel, Can you help me in writing code using matlab program show that , I have probem in how write code for frequence selective fading.
Thank you .

Reply

Krishna Sankar October 8, 2009 at 5:41 am

@ahmed: In OFDM, though the channel is frequency selective, channel as seen by each subcarrier is flat. Hence the expression for flat fading holds good. Please refer to the post http://www.dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

Reply

Hung October 7, 2009 at 8:00 am

hello Krishna Pillai!
I’m a student in Ho Chi Minh City, Viet Nam. I’m searching about “the impact of real channel over MiMo system”. your code is useful. So, we assume that receiver is unknown h matrix and we must explore channel by channel estimation. Do you help me?
Hope you will response me!

Reply

Krishna Sankar October 8, 2009 at 5:35 am

@Hung: Yes, the receiver is trained to estimate the MIMO channel by sending known preamble.

Reply

Anvesh September 13, 2009 at 11:37 am

Thanks a lot, man.
Was very useful.

Reply

thenmozhi September 5, 2009 at 9:30 pm

can you send me the matlab coding for physical layer network coding modulation

Reply

Krishna Sankar September 9, 2009 at 5:43 am

@thenmozhi: Sorry, I do not have matlab code for physical layer network coding modulation

Reply

Tito August 27, 2009 at 5:28 pm

Hi Krishna,

I am working on Forward error correction codes. I have plotted the BER performance curve for Reed solomon codes using BPSK modulation over an AWGN channel from EbNo 0 – 1 . However, the curves are overlapping at the begining between EbNo values 0 and 1 and also in the middle.

Also the curves for convolutional codes overlap at the begining between 0 and 1. and also in the concatenated codes.

Could you please give me a detailed explanationc on the reason why the overlapping occurs and the significance.

The RS codes used were RS(255,191), RS(255,223), RS(255,239) and RS(255,247).
Thanks, hope to hear from you soon.

Reply

Krishna Sankar September 7, 2009 at 5:13 am

@Tito: Firstly, a clarification. When you mentioned about “curve-overlapping”, I guess you meant that – “with coding, the BER becomes poorer than no coding for very low values of Eb/N0″. Agree?

At-least with respect to convolutional codes, I think it can be attributed to the large number of errors in received coded bits, which makes the Viterbi algorithm go haywire.

Reply

Tito September 8, 2009 at 7:28 pm

Thanks that is exactly what i mean. Why does this occur.
And i also have an curve RS curve with and without an interleaver, these curves are overlapping at two points. Why does this occur.

Reply

I.Selvadenniz August 17, 2009 at 5:51 pm

hi,can any one help me to derive BER for physical layer network coding(PNC) modulation scheme…:-)

Reply

Krishna Sankar August 18, 2009 at 3:53 am

@Selvadenniz: Sorry, have not studied PNC coding.

Reply

tommy October 16, 2009 at 5:19 pm

hiii… you have BER for physical layer network coding(PNC) modulation scheme….

Reply

Krishna Sankar October 17, 2009 at 4:15 am

@tommy: Sorry, no

Reply

Alex August 14, 2009 at 5:00 am

Hi Pillai

I would like to ask you a simple question. I am trying to make a simple simulation using a matlab. It is about that one node using SF(spreading factor)=2, and another node using SF = 8 (orthogonal to each) are encoding the data and sending to one node (asynchronous network) with same power but from different distance at the same time. how can i simulate it? when decoding at the receiver, it uses same ovsf code as the node using SF = 8.

Thanks in advance.

Reply

Krishna Sankar August 14, 2009 at 5:15 am

@Alex: Well, let me try to write the pseudo code for this case
y1 = x1*code1; % code with SF=2
y2 = x2*code2; % code with SF=8
n = noise; % AWGN noise, lets take mean=0, variance = 1
r1 = y1*scaling1; % scaling factor for first signal
r2 = y2*scaling2; % scaling factor for second signal
r = r1+r2+n; % receiver collects both signals corrupted by noise
x2Hat = r*code2 % receiver tries to correlate r with code2 to recover x2.

Makes sense?

Reply

sam August 1, 2009 at 1:51 pm

hi everybody
i need simulink’s (matlab) block for accunting BPSK BER

Reply

Diego July 31, 2009 at 5:54 am

Hi, my english is not very good looking, but…what is the noise variance for 16QAM and 64QAM?, AWGN channel.

Reply

Krishna Sankar August 5, 2009 at 5:39 am

@Diego: The noise variance is independent of the modulation scheme. However, I think you might be looking for error rate for different modulation schemes for a given value of noise variance. You may refer posts:
http://www.dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/
http://www.dsplog.com/2008/03/29/comparing-16psk-vs-16qam-for-symbol-error-rate/
http://www.dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/
http://www.dsplog.com/2008/07/08/compare-bpsk-qpsk-4pam-16qam-16psk-64qam-32psk/

Reply

sam July 30, 2009 at 2:29 pm

hi kirishna pillai
i need simulink’s (matlab) block for accunting BPSK BER
thanks

Reply

Krishna Sankar July 31, 2009 at 4:53 am

@sam: Sorry, I do not have Simulink.

Reply

gdkorde July 25, 2009 at 6:01 pm

plz help me for changing code rate and delay spread in bpsk modulation used in hiperlan/2

Reply

Krishna Pillai July 28, 2009 at 4:29 am

@gdkorde: Quick questions:
1/ What is the coding technique used ? Convolutional coding?
2/ What is the model of the multipath channel? Exponential model?

Reply

leth July 18, 2009 at 10:07 am

hi can you tell me how to make adaptive modulation ?

thanks

Reply

leth July 18, 2009 at 9:04 am

hi
i need matlab code for adaptive modulation from BPSK,QPSK,16QAM,64QAM

so if you have not such code, i hope to guide me how to make it , as you know for low SNR we use like BPSK and for high SNR use like 64QAM

so how to make this via matlab?

regards

Reply

Krishna Pillai July 19, 2009 at 8:58 am

@leth: I do not have a code combining BPSK/QPSK/QAM etc to do adaptive modulation. However, you may find individual posts describing these modulation schemes @ http://www.dsplog.com/2008/10/01/download-free-e-book/
As you said, one way to make an adaptive modulation scheme is to define a BER threshold (lets say 10^04) to switch from one modulation scheme to another.

Reply

Vijay July 7, 2009 at 11:05 am

Hi, I am want to plot the pdf for various SNR(Symbol Error) for various modulation schemes. Do you have matlab code for it.

The derivation in this link is SER Vs SNR, How to change the SER to PDF(of SNR)?

Thanks in advance

Reply

Krishna Pillai July 15, 2009 at 4:42 am

@Vijay: I have written an article on error rate for various modulation schemes in dspdesignline.com @
http://www.dspdesignline.com/howto/208801783;jsessionid=3ISGUXHINOVIAQSNDLRSKHSCJUNN2JVN?pgno=1

Further, you may also check out the post
http://www.dsplog.com/2008/10/01/download-free-e-book/

Reply

BOUHAFS July 1, 2009 at 10:18 pm

please simulation for BER MIMO (2,2)

Reply

Krishna Pillai July 2, 2009 at 5:24 am

@BOUHAFS: Please refer to the post
http://www.dsplog.com/2008/10/24/mimo-zero-forcing/

Reply

Moon June 29, 2009 at 5:39 pm

Thank you for your effort…
i have some question
1. y = s + 10^(-Eb_N0_dB(ii)/20)*n;
2. theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10)))
i don`t know why Eb_N0_dB(ii) has minus value…
and
At first term,^(-Eb_N0_dB(ii) is divided by 20 but, at second term Eb_N0_dB is divided by 10.
Why Eb_N0_dB is divided by diferrent value??
My question is very poor, nevertheless i will wait for your comment
Have a nice day

Reply

Krishna Pillai June 30, 2009 at 5:14 am

@Moon: My replies
1/ Before this scaling, the signal term s and the noise term n has the same variance of 1. The term -Eb_N0_dB reduces the noise variance
2/ The scaling is happening on the noise voltage signal, hence the factor of 1/20. In the theoretical equation, note that there is a square root term outside the 1/10 factor. This is equivalent to having 1/20 factor. Agree?

Reply

Srinivas June 27, 2009 at 10:25 pm

Can someone help me out with a Matlab code for this.
For ISI chanell with real coeffnts and BPSK modulation write a Viterbi algo decoder with decoding delay >0 (say ‘delta’)

plot BER vs SNR for varying ‘delta’s

Reply

Srinivas June 27, 2009 at 10:13 pm

Can anyone help me out with a matlab code for this.
For ISI channel with L real coeffnts and BPSK modulation write a Viterbi algo decoder with decoding delay >0

Reply

Krishna Pillai June 30, 2009 at 5:10 am

@Srinivas: I have not done MLSE equalization in multipath channel, but plan to do that in near future.

Reply

jo June 23, 2009 at 9:14 pm

i wanna know what does this statement exactly do
ipHat = real(y)>0;

is it equivalent to
if real(y)>0
real(y)=1
else
real(y)=0
end

thanks

Reply

Krishna Pillai June 25, 2009 at 5:48 am

@jo: Plz refer the reply provided to ahmed

Reply

ahmed June 23, 2009 at 8:41 pm

Hello
i just want to ask about this statement in the code
ipHat = real(y)>0;
what exactly it do
is it equivalent to
if real(y)>0
real(y)=1
else
real(y)=1
end

Thx

Reply

Krishna Pillai June 25, 2009 at 5:47 am

@ahmed: No, your explanation is not correct. As komari mentioned, it is equivalent to
if (real(y)>0)
ipHat = 1
else
ipHat = 0
end

Reply

Ali June 23, 2009 at 8:36 pm

Ok Thanks very much krishna :)

Reply

komari June 22, 2009 at 11:20 pm

please can you tell me what does this instruction do exactly

ipHat = real(y)>0;

is it equivalent to
if (real(y)>0)
ipHat = 1
else
ipHat = 0
end

Thanks

Reply

Krishna Pillai June 23, 2009 at 4:40 am

@komari: Your explanation is correct.
As you may be aware, Matlab provides lots of ‘quick one liner’ ways to do things. :)

Reply

Swetha June 18, 2009 at 10:24 am

Hi All,

Can any one guide me to good source…
How to calculate Bit error probability for given SNR, any modulation technique with error correcting codes(convolution coding).

Please give some information on this.

-Thanks
Swetha

Reply

Krishna Pillai June 21, 2009 at 12:48 pm

@Sweta: The book Digital Communications by John Proakis is a good reference

Reply

RAO June 13, 2009 at 12:30 am

Thanks Krishna for reply.

I want to plot BER vs Eb/No for MPSK and MDPSK. Can u help me in this regard ?

Also do u have code for FSK coherent and non-coherent with corresponding BER vs Eb/No plot?

Your early response will b highly appreciated.

Reply

Olguin June 10, 2009 at 2:55 pm

first of all, thanks a lot for ur job, it´s really useful for all the DSP internet communty.

here my question, I´m carrying out some simulations on simulink. modulating BPSK, spreading w/ gold code, going through awgn, despreading and demodulating BPSK, and at the end I measure the BER.

using simple BPSK mod/demod provided in the communications block set, I´ve got a relative high BER (.5), then I found the so-called “Real BPSK mod/demod” which basically a “real-imag to complex”/”complex to real-imag” block is added to the BPSK mod/demod, and the resulting BER is around .1.

I´ve tried to find unsuccessfully an explanation to this on technical literature.

maybe you know something about that.

Thanks in advance.

Reply

Krishna Pillai June 11, 2009 at 4:49 am

@Olguin: Well, having BER of 0.5 means there is some error in the simulation code. If you wish you refer the post on
(a) BPSK BER with matched filtering
http://www.dsplog.com/2009/05/08/ber-with-matched-filtering/

Hope that helps you to debug the code.

Reply

RAO June 9, 2009 at 8:12 pm

Hello.

I need matlab code for DPSK and also its BER.

regards,

Reply

Krishna Pillai June 10, 2009 at 5:26 am

@RAO: I have a post on Coherent Demodulation of DBPSK
http://www.dsplog.com/2007/09/30/coherent-demodulation-of-dbpsk/
Hope this helps.

Reply

RAO June 10, 2009 at 3:58 pm

thanks Krishna.

Actually i need matlab code for non-coherent detection of either bpsk or dpsk and also corresponding BER vs Eb/No plots.

regards,

Reply

RAO June 10, 2009 at 4:00 pm

sorry. in addition, i want noncoherent detection of bpsk or dpsk for both AWGN AND RAYLEIGH channel.

regards,

Reply

Krishna Pillai June 11, 2009 at 4:50 am

@RAO: Sorry, I have not tried simulating non-coherent detection dpsk.

Reply

RAO June 12, 2009 at 5:12 pm

Thanks Krishna for reply.

I want to plot BER vs Eb/No for MPSK and MDPSK. Can u help me in this regard ?

Also do u have code for FSK coherent and non-coherent with corresponding BER vs Eb/No plot?

Mathew June 9, 2009 at 6:21 pm

I mean 16-apsk modulation sth like that http://commons.wikimedia.org/wiki/File:Const_16APSK.gif

Reply

Krishna Pillai June 10, 2009 at 5:25 am

@Mathew: Sorry, I have not tried simulating 16-APSK. Thanks to you, I just realized that it is used in DVB-S2. I will try to do a write up in future.

Reply

Mathew June 8, 2009 at 2:37 am

Have you got any code to 16-apsk?

Reply

Krishna Pillai June 8, 2009 at 6:02 am
Assad Abbasi June 6, 2009 at 1:03 am

Dear Krishna, thanks for your codes. I am plotting BER for BPSK and QPSK but i am not getting same BER curve. As it should be same for both. I know that the plot should be BER vs EbN0. But how to get EbN0 from SNR? In your codes you have written Eb_N0_dB, is this EbN0?? I think it is SNR. If this is EbN0, why am i not getting same curve for BPSK and QPSK… Please Help

Reply

Krishna Pillai June 7, 2009 at 2:31 pm

@Assad Abbasi: Well, as you said BER vs EB/N0 curve for both BPSK and QPSK should be comparable. In general,
Es/N0 = kEb/N0, where k = log2(M) and M is the constellation size.

I have discussed a post comparing BPSK, QPSK, QAM etc @ http://www.dsplog.com/2008/07/08/compare-bpsk-qpsk-4pam-16qam-16psk-64qam-32psk/
Hope this helps.

Reply

Eduardo Solano June 4, 2009 at 1:55 am

i have a question..
i have a program wich makes bpsk modulation and i need to show Bit error curve for BPSK modulation – theory, simulation (both) as you do here in this page at top.

ok but there is something that happens with simulation curve that appears a little bit more to the right side of teoric curve.

i wanna know a reason why does it happens.

Reply

Krishna Pillai June 7, 2009 at 2:11 pm

@Eduardo Solano: If the simulation curve is happening to the right of the theoretical curve, it typically means that you are adding more noise than what is required. Also make sure that you simulate for atleast 10^6 bits, such that you get statistically accurate results.

Reply

M S Sasidhar June 2, 2009 at 1:15 pm

hi every body can any one tell me the code for “signal to noise ratio using autocorrelation in time domain” using MATLAB

thanks in advance…..

Reply

Krishna Pillai June 7, 2009 at 1:57 pm

@sasidhar: The question is not clear to me. Can you please provide some more details….

Reply

maya May 31, 2009 at 10:26 pm

thnx for ur response,,it means dat u need to have atleast 2 no of rcvd bits at da reciever 2 be compared..but my confusion is that how to use vblast when i am considering diversity mimo,where i have to use combing technique first?? can i implement vblast in dat case or not???

Reply

Krishna Pillai June 1, 2009 at 5:22 am

@maya: Well, try to write the equation in matrix form. For eg, consider a simple case where we have two transmit antennas and 3 receive antennas. The matrix dimensions will be of:
y = Hx + n, where
y – received symbols of dimension [nrx x 1]
H – channel matrix of dimension [nrx x ntx]
x – transmit symbols of dimension [ntx x 1]
n – noise of dimension [nrx x 1]

If we write the zero forcing equalizer for this equation, then we can find that
W = (H^H*H)-1*H^H

This equalization also performs the diversity combining via Maximal Ratio Combining way. Does this help?

Reply

maya May 29, 2009 at 5:38 pm

HEY sir can u plzz help me in getting the main concept of vblast detection scheme,,i am not geting how it estimates the data…

Reply

Krishna Pillai May 31, 2009 at 8:43 pm

@maya: Well, understanding V-BLAST with Zero Forcing equalization is the most simplest way. From our linear algebra days, we know that if we have two unknowns, we need atleast two equations to solve them.

Adapting them to MIMO V-BLAST, the two unknowns are the unknown transmitted data, and the two equations are provided by the two receive antennas. Just putting a simple example,
y1 = a*x1 +b*x2
y2 = c*x1 + d*x2
where
y1, y2 are received symbols
a,b,c,d are channel taps (which are known) and
x1, x2 are unknown transmit symbols.

The following post might be of bit more help.
http://www.dsplog.com/2008/10/24/mimo-zero-forcing/

Hope this helps.

Reply

aam_log May 28, 2009 at 7:26 pm

Dear krishna
I hope you are fine. I am in 5th semister of my bachelors of telecommunications. So I am new to this field and facing lots of difficulties. I find your site very impressive and have joined it recently. Can you kindly tell me why we normalize things? thnx

Reply

Krishna Pillai May 31, 2009 at 8:36 pm

@aam_log: Good luck for your studies. We normalize, because we want to have a fair comparison when trying out different approaches….

For eg, if we are comparing 100apples with 100grapes, we would want to know the price per kilogram, no?

Reply

Ideal May 27, 2009 at 12:57 pm

Dear Krishna
how can we simulat the angular delay profile. can you just give me simple example plz?

Reply

Krishna Pillai May 31, 2009 at 8:31 pm

@Ideal: Sorry, am not familiar with modeling angular profile.

Reply

kanchana May 15, 2009 at 1:09 pm

hello sir

i am doing my project in cdma can u tell me the purpose of rake receiver and details about maximum ratio combining

Reply

Krishna Pillai May 20, 2009 at 5:24 am

@kanchana: Well, I have not quite discussed about cdma in the blog till date. Hope to do so in future.
I beleive the intent of the rake receiver is to coherently combine information from all the multipath taps such that the bit-error rate is reduced. I have posted about maximal ratio combining for a 1 transmit 2 receive receive diversity case.
http://www.dsplog.com/2008/09/28/maximal-ratio-combining/
Though the context is different, I think you should be able to adapt that to suit your needs.

Good luck.

Reply

Student May 12, 2009 at 6:04 pm

Dear Krishna Pillai

Thank u. I am really happy and trying to do what u have suggested.

Reply

Student May 6, 2009 at 8:17 am

Dear Krishna Pillai :
Please reply my question dated April 30, 2009 at 9:37 am.

Regards,

Reply

Krishna Pillai May 12, 2009 at 5:16 am

@Student: I just did. Hope you are happy with the response. Sorry for the delay in my reply. Good luck.

Reply

bowang May 5, 2009 at 7:07 pm

wah ini dia data yang aku cari-cari akhirnya menemukan yang namanya BPSK
thanks yaaaaaaaaaaaaaaaa…
sip sip sip sip

Reply

Krishna Pillai May 12, 2009 at 5:10 am

@bowang: good

Reply

Elias April 30, 2009 at 1:42 pm

Bonjour
Je cherche des programmes MATLAB pour la génération des codes LDPC Quasi Ciclique
Alors si vous avez des programmes ou des liens utiles prière de me les envoyer a ce mail
eliasknopfler@hotmail.com
Je vous remercie

Reply

Krishna Pillai May 12, 2009 at 4:42 am

@Elias: Sorry, I have not discussed LDPC coding till date. Hopefully in the near future.

Reply

Student April 30, 2009 at 9:37 am

Dear Krishna Pillai
Thanks a lot for ur suggestion.When I domodulate following code it gives a simple sine wave.How can I demodulate it?
close all
b=[0 1 1 0 1 0 1 0 0 1];
fc=10;
n=1;
while n<=length(b)
if b(n)==0 %0 is -1
tx=(n-1)*0.1:0.1/100:n*0.1;
m=(-1)*sin(2*pi*fc*tx);
plot(tx,m,’LineWidth’,1.5);grid on;
else
tx=(n-1)*0.1:0.1/100:n*0.1;
m=(1)*sin(2*pi*fc*tx);
subplot(2,1,1)
plot(tx,m,’LineWidth’,1.5);grid on;
hold on;
end
n=n+1;
end
title(‘BPSK modulated Signal’)

How coherent detection can be applied on it?
Thanks in advance.

Regards,

Reply

Krishna Pillai May 12, 2009 at 4:39 am

@Student: hmm..let me try to understand. For bit0 you are sending -ve sine wave, and for bit1 you are sending +ve sinewave right. At the receiver you cmay undo the effect of the sine wave by multiplying the received signal with the sine wave and taking the mean. Then perform hard decision decoding on that signal.
Does that help?

Reply

bwk April 29, 2009 at 6:46 pm

Hi,
I would need equations of bit error probability for this modulation technique: MSK, GMSK, QPSK, ASK. Do you know it?
Thank for answer

Reply

Krishna Pillai April 30, 2009 at 5:46 am

@bwk: I have not tried simulating MSK/GMSK. Something to do in future. However, you may look at the posts:
a/. Symbol error rate for QPSK
http://www.dsplog.com/2007/11/06/symbol-error-rate-for-4-qam/
b/. Symbol error rate for 4-PAM
http://www.dsplog.com/2007/10/07/symbol-error-rate-for-pam/

Reply

Student April 29, 2009 at 5:30 pm

Dear Krishna Pillai
How can I correlate demodulated signal and binary code in BPSK ?I mean reteriving back of binary code.

Reply

Krishna Pillai April 30, 2009 at 5:44 am

@Student: At the receiver, using hard decision decoding you can find out whether the received symbol is +1 or -1. Then we can easily map to +1 to bit1 and -1 to bit0 respectively.

Reply

Oluwafemi April 16, 2009 at 9:05 pm

Please i dont know how i can acess the e book.
I am working on super orthogonal space time turbo codes in OFDM systems and will need this e book .Thank u

Reply

Krishna Pillai April 18, 2009 at 8:11 am

@ Oluwafemi: I had mailed you the instructions. Please check your inbox.

Reply

Student April 13, 2009 at 12:30 pm

Dear Krishna Pillai :
How can I change Amplitude Modulation to BPSK(y1 = ammod(x1,Fc1,Fs) to bpsk . I hope for a positive response.
clc
close all
clear all

t = 0:0.00001:0.001;

Fc1 = 1000;

Fs = 12000;
y1 = 1;
x1 = cos(2*pi*1000*t);

in_p = input(‘\nDo you want to enter user Y/N: ‘,’s');

if(in_p == ‘Y’ | in_p == ‘y’)
y1 = ammod(x1,Fc1,Fs);
end

Reply

Krishna Pillai April 16, 2009 at 5:40 am

@Student: Sorry, I do not have the functions ammod(). Maybe the post on symbol error rate computation using 4-PAM be of help.
http://www.dsplog.com/2007/10/07/symbol-error-rate-for-pam/

Reply

Einsein April 12, 2009 at 8:29 pm

Hello,

Do you know how you can build a zero-crossing detector or delay-and-multiply detector for the FSK.

Thanks.

Reply

Krishna Pillai April 16, 2009 at 5:35 am

@Einsein: I have written a post on BER computation for FSK using coherent demodulation. That may provide some pointers
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/
Hope this helps.

Reply

R@y April 12, 2009 at 12:49 am

Hi, can you help with this issue,consider QPSK transmission over flat fading Rayleigh channels and a 1×2 system.The channels on the different diversity branches are assumed to have the same variance and the noise samples are assumed to be uncorrelated and circularly symmetric Gaussian variables with the same variance.
Consider three combining schemes: MRC, EGC and SC, for plot the BER versus the average signal-to-noise ratio (SNR).
I hope you can help me

Reply

Krishna Pillai April 16, 2009 at 5:27 am

@R@y: Using BPSK modulation, I have written articles for a 1 transmit, 2receive system in a flat fading uncorrelated Rayleigh channel.
http://www.dsplog.com/2008/09/06/receiver-diversity-selection-diversity/
http://www.dsplog.com/2008/09/19/equal-gain-combining/
http://www.dsplog.com/2008/09/28/maximal-ratio-combining/
Hope this helps.

Reply

Murali Kris April 8, 2009 at 7:26 am

Hi Krishna,

All your posts have been very helpful and easily understandable. I was looking for a code that has all the modulations(bpsk,qpsk,mpsk,ask,bfsk,msk etc…) in a single program and to compare their BER, PSD curves. please let me know if you have any.

Thanks

Reply

Krishna Pillai April 11, 2009 at 6:48 am

@Murali: No, I have not posted a single code putting all the BER curves in a single plot. However, I have discussed about multiple modulation schemes in dspdesignline.com
http://www.dsplog.com/2008/07/08/compare-bpsk-qpsk-4pam-16qam-16psk-64qam-32psk/
Hope this helps.

Reply

Shahrukh April 1, 2009 at 8:35 pm

pls sumbody help me out!!!…………:(….

Reply

Shahrukh March 30, 2009 at 10:53 pm

Can someone pls provide me the matlab code for the below mentioned project work:

A randomly generated bit stream should be transmitted through an AWGN channel using BPSK. THe received symbols should then be converted again to a bit stream. The received bit stream should be compared with the original one to determine the total number of errors and hence the bit error probability. The probability of error should be calculated for several values of EB/No.
Once the above system is succesfully simulated an additional block of channel coding should be incorporated in the system. A (15,11) Hamming code should be used for this purpose. Simulation of this should be performed to increase the performance of the system.

RESULT to be DISPLAYED:

1. Bit error probability versus EB/No graph of BPSK
2. Bit error probability versus Eb/No graph of BPSK using equation
3.Bit error probability versus Eb/No graph of BPSK system with channel coding/decoding

The written code shuld allow the user to perform simulation for any number of bits and for any range of Eb/No.

THANKS..

Looking forward for your assitance.

Reply

Krishna Pillai April 4, 2009 at 4:26 pm

@Shahrukh: My replies:
1. Example Matlab code is provided in this post
2. The equation for BER for BPSK for a given value of Eb/N0 is provided in this post
3. I have not tried simulating with Hamming code. However, you may check the article on convolutional coding
with Viterbi decoding
http://www.dsplog.com/2009/01/04/viterbi/

Hope this helps.

Reply

shoumi March 18, 2009 at 2:47 pm

hi
How can i calculate throughtput for a multi-hop wireless network using matlab. please give me some suggestion ragarding this….

thanks

Reply

Krishna Pillai March 21, 2009 at 9:10 am

@shoumi: Sorry, am not familiar with modelng multi-hop networks.

Reply

Krishna Pillai March 21, 2009 at 9:11 am

@shoumi: Sory, I have not worked on modeling multihop wireless networks.

Reply

Krishna Pillai March 21, 2009 at 9:12 am

@shoumi: Sorry, I have not worked on modeling multihop wireless networks.

Reply

mrKim November 13, 2012 at 8:33 am

Dear Shoumi

Did you find material about calculate throughtput for a multi-hop wireless network using matlab ? Please share me if you have. I need it very much
my email: nguyenkimhieuha@gmail.com

Thank you

Reply

Nafis March 18, 2009 at 4:09 am

Thanks for your codes.It’s helped me a lot.But I want to replace Eb/N0 as SNR how can I do it.Could you pls help me urgently.

Thanking you

Reply

Krishna Pillai March 21, 2009 at 9:07 am

@Nafis: For BPSK. Eb/N0 is same as SNR. Agree?

Reply

Matt K March 17, 2009 at 7:13 pm

Hi there, very useful site. I have a couple of questions regarding the BPSK:

1) Could you go in to a little more detail why you use complex noise vs. real. Although it doesn’t make a difference for BPSK, I’m assuming it actually will with other modulation methods. I didn’t see this in any of my textbooks.

2) In your code for the BPSK, you divide by 20. Shouldn’t that be 10? Given an SNR in dB, we get S/N0 = 10*log(SNR-dB / 10).
This gives N0 for a given signal power S.
The variance^2 = N0/2 and if we assume 0 mean, this gives us our AWGN, which is a random variable describing the noise amplitude. In my simulation, if I use 10 instead of 20, my results were way off, but 10 gives a perfect match with theory.

Thanks much,
Matt

Reply

Krishna Pillai March 21, 2009 at 9:04 am

@ Matt K: My replies
1). Yes, for BPSK the noise component on the imaginary arm is ignored. To make the noise model same as with other modulation schemes, I kept it as complex.
2). The division by 20 is to convert the dB to scale the voltage signal. In my simulation model, the noise term n is a Gaussian random variable with mean 0 and variance 1. Therefore, I am scaling the noise voltage by 10^(-Eb_N0_dB(ii)/20)*n. Thats why I used 20.
In general, it depends on how one creates the model. Different people have different coding style. However, its the end result which matters. :)

Hope this helps.

Reply

nyna March 13, 2009 at 6:54 pm

tq krishna…i understand it more than before..i really appreciate it..
however can i ask u bout the graph of BPSK between simulation and theoretical in term of BER vs SNR…
how the shape of graph become like that?

Reply

Krishna Pillai March 21, 2009 at 7:53 am

@nyna: The shape of the curve is determined by the probability of error which we have defined in the post.

Reply

Aditya March 13, 2009 at 11:48 am

Hey krishna,

I am new here. I find this site really very useful. Thanks for everything. I have a question reg BPSK sim. I did it with awgn function and I am not getting theo and sim graphs overlapping. Please answer this as soon as you get time . thanks

Reply

Krishna Pillai March 21, 2009 at 7:44 am

@Aditya: You should have got similiar curves with awgn() function too. Is the slope of the graphs matching. Then its quite likely some power normalization issue.

Reply

shoumi March 10, 2009 at 1:25 pm

hi

I wanna matlab simulation code for AODV routing protocol. Can you help me ….

Reply

Krishna Pillai March 21, 2009 at 7:01 am

@shoumi: Sorry, I have not worked on AODV protocol.

Reply

nyna March 8, 2009 at 7:08 pm

krishna can u help to understand more about the function of transmitter filter in BPSK and also how the ISI(intersymbol interference)will occur at transmitter filter??

Reply

Krishna Pillai March 8, 2009 at 7:52 pm

@nyna: In the transmitter, we will first be converting bits into analog voltage (+1/-1 in the case of BPSK). However, we cannot transmit them as is, as it will occupy lots of spectrum (which is not desirable). Hence we need to do filtering. However, when doing filtering, we introduce ISI (inter symbol inteference) i.e each symbol may interfere with the next symbol and so on.

So, the question is: can we do filtering without introducing ISI? The answer is YES. There are simple filters like rectangular, ideal filter like sinc and practical filters like raised cosine, which can do the job. You may read more about them @
http://www.dsplog.com/2008/04/14/transmit-pulse-shape-nyquist-sinc-rectangular/
http://www.dsplog.com/2008/04/22/raised-cosine-filter-for-transmit-pulse-shaping/
http://www.dsplog.com/2008/05/01/eye-diagram-plot-matlab-raised-cosine-filter/

Hope this helps.

Reply

bullah March 3, 2009 at 10:58 pm

hai..krishna..i want ask you the function of hamming code and bCh code..it because i already simulate the block using that coding…can you give me the formula for i’m calculate theory the bit error rate when using coding for i compare between theory and simulate…..also can you give me the graph ber vs Eb/No when coding..tq

Reply

Krishna Pillai March 5, 2009 at 5:35 am

@bullah: Sorry, I have not discussed hamming codes or BCH codes till date. You may look at the posts describing convolutional coding and Viterbi decoding @
http://www.dsplog.com/tag/viterbi

Hope this helps.

Reply

Einstein March 2, 2009 at 3:38 pm

I want to do a matlab simulation for the the GFSK. Plot the BER vs. EbNo.

Reply

Krishna Pillai March 5, 2009 at 5:08 am

@Einstein: Sorry, I do not have Matlab simulations with GFSK. However, you may check up the post on BER for FSK in AWGN @
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/

Hope this helps.

Reply

pragya August 23, 2009 at 1:28 am

sir,
i want matlab programs for MCCDMA,whtever u hve on dis topic ,plz mail me as soon as possible,since MCCDMA is my thesis topic, but i m facing many prblms regarding matlab programs

thank u,
pragya

Reply

Krishna Sankar August 24, 2009 at 4:59 am

@pragya: Sorry, I have not written Matlab models on MC-CDMA.

Reply

mohamed March 2, 2009 at 3:21 pm

The term 10^(-Eb_N0_dB(ii)/20) is for scaling the noise power as per the defined bit to noise ratio, why divided it by 20 >>??to convert it to voltage

Reply

Krishna Pillai March 5, 2009 at 5:05 am

@mohamed: Yes, divided it by 20 is to convert to voltage.

Reply

santosh February 21, 2009 at 10:40 pm

sdadasdad

Reply

mansi February 21, 2009 at 11:09 am

hi i have plotted the results for some coding
i just want is biterr with no coding

i.e. simply take msg, modulate add noise and demodulate

now find the biterr or symerr for oiginal msg and recovered msg

pls help as early as possible

Reply

Krishna Pillai February 22, 2009 at 2:42 pm
nyna February 12, 2009 at 6:37 pm

thanks krishna…i’m really appreciate it..thanks so much

Reply

Krishna Pillai February 12, 2009 at 6:22 am

@invizible soul:
I thought I replied already. Plz check my response @
http://www.dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/comment-page-2/#comment-5038

Reply

invizible soul February 11, 2009 at 5:37 pm

hi … i think my username “invizible soul” has really made me invizible :) … as no one has answered my questions …
waitinn……

Reply

nyna February 11, 2009 at 9:49 am

hello..
who will help me to understand the function of a filter in a block diagram of a basic communication system in BPSK?
What the purpose of finding the value of delay in the program of BPSK?

Reply

Krishna Pillai February 12, 2009 at 6:44 am

@nyna: Filter is used for controlling the spectrum of the transmission. However, when doing the filtering we do not want to introduce ISI. Hence we typically go for filters like raised cosine etc. You may find some more details @
http://www.dsplog.com/2008/04/14/transmit-pulse-shape-nyquist-sinc-rectangular/
http://www.dsplog.com/2008/04/22/raised-cosine-filter-for-transmit-pulse-shaping/
http://www.dsplog.com/2008/05/01/eye-diagram-plot-matlab-raised-cosine-filter/

Hope this helps.

Reply

invizible soul February 9, 2009 at 6:06 pm

kindly reply me !!! i am still waiting … from where we get this expression:
10^(-Eb_N0_dB(ii)/20)

thnx

Reply

wap February 9, 2009 at 5:46 pm

thanks khrishna with your help………..

i late reply n visit your site coz im busy….
how abaut this???
% BER_sic=sim_sic_fn(SNR_dB, P, Nb, code_matrix, chan_type)
% return bit error rate of the sic receiver in AWGN or rayleigh fading
%
% PARAMETER:
% SNR_dB=signal-ti-nopise ratio in dB
% P=power control vector, P(i)=transmitted power of i-th user
% Nb=number of transmitted bit
% code_matrix=matrix of the spreading code used
% chan_type=channel type(1=AWGN, 2=rayleigh fading channel)
%
% output:
% BER_sic=bit error of the sic receiver
%
function BER_sic=sim_sic_fn(SNR_dB, P, Nb, code_matrix, chan_type)

BER_sic=zeros(size(SNR_dB));
K=length(P); %number of user
N=size(code_matrix,2); %spreading factor

G(:,1)=code_matrix(33,:)’;
G(:,2:K)=code_matrix(1:K-1,:)’;

Reply

Krishna Pillai February 10, 2009 at 8:12 pm

@Wap: Sorry, I did not get your question

Reply

invizible soul February 6, 2009 at 1:59 pm

hi hope you are fine. In your code you have scaled the noise with the term 10^(-Eb_N0_dB(ii)/20)
my question is why we do this?I mean why we need to scale the noise power as per the defined bit to noise ratio? Any references will help me a lot
fire back soon plz !!!

Reply

Krishna Pillai February 10, 2009 at 7:53 pm

@invizible soul: Sorry for the delayed response. I am traveling with out a reliable access to internet.

In this analysis, our objective is to analyze the impact of noise on the reliable decoding of BPSK modulation. To analyze the impact, we need to find out the performance (bit error rate) for different values of noise. Hence we scale the noise by noise power.

Hope this helps.

Reply

invizible soul February 13, 2009 at 6:59 pm

thanx alot krishna … sorry i missed it …

Reply

santosh February 21, 2009 at 10:39 pm

@manju I got a better solution for your question.We need to untilmately multiply with standard deviation of noise so we get 20 there.

Reply

T-dog March 24, 2010 at 12:55 am

SNRdB = 20 log (Asignal / Anoise)
-SNRdB = 20 log(Anoise / Asignal)
-SNRdB/20 = log(Anoise / Asignal)
10^(-SNRdB/20) = Anoise/Asignal <——— noise amplitude scaling factor.

Reply

Krishna Sankar March 28, 2010 at 1:50 pm

@T-dog: Thanks.

Reply

bullah February 3, 2009 at 9:15 am

who can help me to find the formula bit error rate when coding for bpsk…?

Reply

Krishna Pillai February 10, 2009 at 7:18 pm

@bullah: It depends on the coding which is applied. There are couple of posts discussing BPSK in AWGN with rate 1/2 convolutional coding.
Convolutional coding
http://www.dsplog.com/2009/01/04/convolutional-code/
Hard decision Viterbi
http://www.dsplog.com/2009/01/04/viterbi/
Soft input Viterbi
http://www.dsplog.com/2009/01/14/soft-viterbi/

Hope this helps.

Reply

wap January 30, 2009 at 12:18 pm

Hi krishna

can any one help me for code SIC (Successive Interference Cancellation).i will tray it for study…..

thanks………………..

Reply

Krishna Pillai January 31, 2009 at 6:38 am
manju January 26, 2009 at 2:51 pm

hi..how 2 generate -ve rectangular pulse 4 bin sym 0 & +ve rectangular pulse 4 bin sym 1

Reply

Krishna Pillai January 27, 2009 at 6:24 am

@manju: You may use the following steps provided in the Matlab code snippet
clear all
N = 7; % number of bits
ipBit = rand(1,N) > 0.5; % random 1′s and 0′s
ipMod = 2*ipBit – 1; % converting 1′s to 1 and 0′s to -1
os = 4; % oversampling factor
ipMod_os = [ipMod; zeros(os-1, length(ipMod))]
ipMod_os = ipMod_os(:).’;
ipMod_filter = conv(ipMod_os,ones(1,os)/os);

Does that help?

Reply

mak December 25, 2008 at 6:44 pm

Hi all

hope u all r f9

can any one help me for BER performance of adaptive modulation
(QPSK,4QAM,16QAM)in AWGN only I need to draw them in single graph

thankz in advance

Reply

Krishna Pillai December 26, 2008 at 6:17 am

@mak: As I understand from your query, you want to switch from one modulation scheme to another based on a defined error rate constraint. For eg, for lower SNR’ you would want to use BPSK, then move on to QPSK/4QAM for medium SNR’s and then hit 16QAM at high SNR’s.

I do not have any code explicitly doing this, but I would think that it would be reasonably easy to build using the following posts:
(a) Bit Error Rate (BER) for BPSK modulation
(b) Symbol Error Rate (SER) for QPSK (4-QAM) modulation
(c) Symbol Error Rate (SER) for 16-QAM
(d) 16QAM Bit Error Rate (BER) with Gray mapping

Hope this helps.

Reply

leth March 4, 2009 at 3:02 pm

dear sir

i want simulation for adaptive modulation

please if have such code send it to me

thanks

Reply

Krishna Pillai March 5, 2009 at 5:35 am

@leth; Sorry, I have not discussed adaptive modulation

Reply

Zoe December 22, 2008 at 12:56 am

Hi Krishna,
Thanks for the good information.

Could you shade light on the derivation of Sigma^2 = No/2 from correlation and spectral density of noise stand point?

Thanks,
Zoe

Reply

Krishna Pillai December 25, 2008 at 7:29 am

@Zoe: The term N0/2 corresponds to the spectral density of white noise. In typical systems, we experience white noise filtered by an ideal LPF. The variance of this filtered noise contributes to the noise term in the system.
You may look at chapter 9 in Communication Systems – An introduction to Signals and noise in Electrical Communication by A. Bruce Carlson, Paul Crilly, Janet Rutledge for further details.
Hope this helps

Reply

Krishna Pillai November 25, 2008 at 5:55 am

@Ideal: It just means that any value of y (real component) greater than 0 is assigned to 1 and if less than 0 is assigned as 0. This is called hard decision decoding.

Soft decisions – where we do not decide on what was transmitted based on the received constellation – are used typically when there is a decoder block (like Viterbi) following the constellation demapping.

Does this help?

Reply

Ideal November 24, 2008 at 4:57 pm

hi
Dear Krishna,

% receiver – hard decision decoding
ipHat = real(y)>0;
here what do you mean by hard decision decoding? plz reply in brief.

Reply

Krishna Pillai November 22, 2008 at 7:51 am

@Ideal: So you are able to plot both the curves using independent functions/scripts, but not able to combine them. Correct? This should be a reasonably easy aspect to resolve.
You can have a main script which generates the transmit symbol, Eb/No values etc. Pass it two function
(a) for awgn channel y = x + n,
(b) for rayleigh channel y = hx+n
Each function will count equalize, count the errors and report the number of errors for each value of Eb/No.

That should address your concern. Hope this helps.

Reply

Ideal November 21, 2008 at 2:15 pm

Dear Krishna,

I have made a program for BER of BPSK in AWGN and Rayleigh fading channel, now I want to combine the both results in one graph, when I combine the results, the curve for rayleigh change but for awgn not change, can you give any idea what should i do, either i make a functions of both separately and call in one program or i should do something else?

anyone have idea about it plz comment

Reply

Krishna Pillai November 15, 2008 at 8:42 am

@Sky Stradlin: There is noise on the real and imaginary dimension. So, to make the total variance of the complex noise to unity, there is scaling by 1/2.

Reply

Sky Stradlin November 14, 2008 at 5:42 pm

for QPSK modulation, the variance is

sigma = 1/sqrt(10.0^(snr/10.0));
sigma=sigma/2;

Do you have any idea why it has to devide by 2?

Thanks alot

Reply

banovic mladen November 9, 2008 at 1:17 am

exelent!

Reply

Krishna Pillai November 5, 2008 at 5:56 am

@grad student: Yeah, thanks for the suggestion. I agree that your proposal will make the text even more readable.

Anyhow, may I recommend to keep status quo given that the current text is not making it very difficult for the reader.

Reply

poor grad student November 4, 2008 at 10:25 pm

Nice graphics and derivation.

Might want to consider using a separate integration variable for the definition of the erfc function, since the variable x was used for both the erfc argument and integration variable.

Perhaps just use ‘z’ or ‘y’ for the erfc integration variable, i.e., erfc(x) = 2/sqrt(pi) * Integral_x_inf { exp(-z^2/2)*dz } . This will then make it clear that the erfc argument ‘x’ is used to modify the integration limits, as opposed to the actual function being integrated.

Reply

Krishna Pillai October 24, 2008 at 6:32 pm

@Hussein: Thanks. I do not have the codes, but I would think that it will be reasonable to extend the available simulation models to 16QAM case.
For 16-QAM in AWGN (without OFDM) you may look at the posts,
URI: http://www.dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/
URI: http://www.dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

For extending them to OFDM, you may use the following posts as reference:
http://www.dsplog.com/2008/06/10/ofdm-bpsk-bit-error/
http://www.dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

Hope this helps.

Reply

banafsh May 4, 2012 at 1:47 am

hi mr krishna
i want your mail becauce i have many problem about matlab programming
plz send to me your mail
thanks

Reply

Krishna Sankar May 8, 2012 at 5:21 am

@banafsh: you can use this comments section

Reply

Hussien October 24, 2008 at 6:24 am

Hi Krishna

thank you very much for Your simulation and theory prgram, really they are very useful. Do you have the matlab code for OFDM with 16-QAM in AWGN and Rayleigh Channels.
Best Regards
Hussien

Reply

Krishna Pillai October 8, 2008 at 5:51 am

@Micman: Thanks. I have written a post on symbol error rate computation for QPSK in AWGN.
Symbol Error Rate (SER) for QPSK (4-QAM) modulation
URI: http://www.dsplog.com/2007/11/06/symbol-error-rate-for-4-qam/

Maybe that helps.

Reply

Micman October 8, 2008 at 1:02 am

Hello Krishna

Your simulation and theory prgram is very useful. Do you have the matlab code with qpsk symbols ? Would be great !

I want to compare the theoretical bit error curve for qpsk with a simulated bit error curve with a zero force equalizer. Can you please give me an advice of how to implement this.

Thank you in advance

Best regards

Micman

Reply

Krishna Pillai September 28, 2008 at 11:28 am

@siddhartha: I have written a post on Coherent deomdulation of DBPSK (Differential Binary Phase Shift Keying).
URI: http://www.dsplog.com/2007/09/30/coherent-demodulation-of-dbpsk/

Please check out. Hope this helps.

Reply

siddhartha September 28, 2008 at 1:22 am

hey krishna,
can you please help me with the case of DPSK

Reply

Krishna Pillai September 17, 2008 at 4:52 pm

@farie: The demodulation approaches for PSK is a different from QAM. For 16-PSK case, you can find two posts:

Symbol Error Rate for 16PSK
http://www.dsplog.com/2008/03/18/symbol-error-rate-for-16psk/

Bit error rate for 16PSK modulation using Gray mapping
http://www.dsplog.com/2008/05/18/bit-error-rate-for-16psk-modulation-using-gray-mapping/

You should be able to modify the code for 16-PSK to 8-PSK case.

For 16-QAM case, there are two posts on error rate computation:

16QAM Bit Error Rate (BER) with Gray mapping
http://www.dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

Symbol Error Rate (SER) for 16-QAM
http://www.dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

Hope this helps.

Reply

Krishna Pillai September 17, 2008 at 4:48 pm

@ravi kumar: In AWGN, there should not be any advantage by using OFDM modulation. OFDM can be thought of as a simple up-conversion scheme where each information gets multiplied on different sub-carrier frequencies.

However, the BER difference should come in multipath simulations.

Reply

farie September 17, 2008 at 2:07 am

hi,

Is there a demodulation matlab code which i can apply on most modulation methods like 8 psk, QPSK, 16QAM..etc.

Also do you have 8psk and 16 QAM modulation and demodulation codes in matlab?

thank you

Reply

ravi kumar September 16, 2008 at 11:06 pm

hi,
I do not understand why the BER curves for both BPSK and BPSK with OFDM are almost same where the BPSK with OFDM get
advantage i.e., decrease in BER in case of BPSK with OFDM.
So please give me the idea by differentiate the two curves and how the BER can be decreased with OFDM as soon as possible. iam waiting for u r response hopefully,thanku

Reply

Krishna Pillai September 9, 2008 at 9:39 am

@antiwina: You are right, the imaginary component is ignored. Infact if you see the simulation model, for demodulating the symbol, we use only the real part of the received signal.

However, our definition of noise is with a variance of N0/2 on the real arm and N0/2 on the imaginary arm.

Reply

antiwina September 8, 2008 at 8:16 pm

Hi,

I do not understand why a complex gaussian noise is required. The source here belongs to a BPSK modulation so I think, in practice we have a real noise, because we do just activate the in phase component and not the quadrature phase component.

Reply

khurshid September 7, 2008 at 2:56 am

hi, hope every1 doing well. all the posts are very useful
thanks

Reply

Krishna Pillai July 30, 2008 at 6:11 am

@Vinay:Thanks.
The code is present in this post. Click here to download
http://www.dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/#Simulation%20Model

Reply

Vinay Kumar July 29, 2008 at 12:43 pm

i m very satisfy to this site, bcause it is very hepful to me to make mmy project. if u have bpsk matlab code then send me .

Reply

Krishna Pillai June 12, 2008 at 5:39 am

@rahul: Thanks.
I believe you are looking for the code for transmit pulse shaing filter. You can look at the article and the code in the posts with the tag ‘pulse-shaping’
http://www.dsplog.com/tag/pulse-shaping/
That should help you get going.

Btw, what is pulse sampling?

Reply

rahul June 11, 2008 at 8:57 pm

thanks a lot code is very useful

even i want a code using upsampling and pulse sampling in BPSK mod and downsampling and pulse sampling in BPSK demod

Reply

marjano June 8, 2008 at 2:35 am

thank you but it is not exactly what I’m schearching about :/
I need code for modulation BPSK/PM or only BPSK

Reply

Krishna Pillai May 30, 2008 at 5:34 am

@marjano:
The link to the code is provided just above the figure. Anyhow attaching the link again
Please click here to downlod

Reply

marjano May 29, 2008 at 9:52 pm

please send me a source code for bpsk modulation in matlab

Reply

Krishna Pillai May 17, 2008 at 3:34 pm

@Jhony: If I may put very briefly, fading is the characteristic of the wireless channel. The channel (read enviornment) will vary with time and will exhibit different behaviour for differnt frequencies.

One of the most simplest and useful model of fading is to visualize it as filter whose coefficients change in time.

Ofcourse, this is a simplistic description. For a detailed overview, may I recommend chapter 2 from the book
Fundamentals of Wireless Communication – David Tse, Pramod Viswanath

Reply

Jhony May 15, 2008 at 6:46 pm

hi i hope you are in good health. Can you please tell me what a fading co-efficient is? and what does it signifies in few lines. I shall be very thankful to you.

Reply

Jhony May 13, 2008 at 7:42 pm

thanks alot … u helped me alot i m very happy to learn all this … thanks once again … and plz keep helping me as i want to learn …

Reply

Krishna Pillai May 13, 2008 at 7:34 pm

[randn(1,N) + j*randn(1,N)] generates complex Gaussian noise with mean 0 and variance 2. To make the variance to 1, the scaling factor of 1/sqrt(2) is used.

yes, the j term is for complex noise.

Reply

Jhony May 13, 2008 at 7:27 pm

1/sqrt(2)*[randn(1,N) + j*randn(1,N)];

1/sqrt(2) ==> this is the scaling term?
j*randn(1,N) ==> this is to generate complex noise values?
I am thankful to u for helping me

Reply

Krishna Pillai May 13, 2008 at 7:21 pm

@Jhony: The randn() function generates a random variable having Gaussian distribution and the spectrum of this random variable is same across frequencies. Hence the name White Gaussian Noise (WGN).

This is then Added to the signal, hence the name Additive White Gaussian Noise (AWGN)….

Reply

Jhony May 13, 2008 at 7:11 pm

yeah ! trying to get hold of things slowly now… i hope u dnt mind me asking foolish and lots of Qz…
about the formula u uzed for awgn … i didnt get how it produces awgn … :(

Reply

Krishna Pillai May 13, 2008 at 7:07 pm

@Jhony: Thanks. Am doing good. How are u? Glad to notice that you are not desperate now :)
Typically, to keep the code simple, I tried to avoid in-built functions. The randn() function + scaling the does the job. Thats all.

Reply

sitharam March 20, 2010 at 6:29 pm

hi krishna pillai i am doing project on viterbi decoder i want the matlab code for the viterbi decoder if u have the code please send me

Reply

Krishna Sankar March 28, 2010 at 2:07 pm

@Sitharam: Plz check out
http://www.dsplog.com/tag/viterbi/

Reply

Jhony May 13, 2008 at 5:54 pm

hi
hope you are doing fine…in the matlab program u have given here, why didnt you use the awgn matlab function to introduce the noise? why have we taken this formula? thanks

Reply

Krishna April 12, 2008 at 7:44 pm

@babar:
The term 10^(-Eb_N0_dB(ii)/20) is for scaling the noise power as per the defined bit to noise ratio. The for loop is for computing the bit error rate for each Eb/N0 value.

Reply

srinivas March 11, 2009 at 5:31 pm

Hi..
Why you are multiplying ‘n’ with The term 10^(-Eb_N0_dB(ii)/20).
The didnot understans the concept behind this from the previous posts..

Reply

Krishna Pillai March 21, 2009 at 7:09 am

@srinivas: This is to scale the noise term ‘n’, so that we can obtain BER for different values of Eb/No. In the simulations, we define Eb/No in dB. To convert dB to define a scaling term for noise voltage, we use 10^(Eb_N0_dB/20).

Hope this helps.

Reply

babar April 11, 2008 at 7:12 pm

hello! i am unable to understand the FOR loop operation in this code kindly explain a bit
thnaks in advance

Reply

babar April 11, 2008 at 6:48 pm

nope i didnt get it plz explain it a bit i shal be thankful

Reply

babar April 11, 2008 at 6:46 pm

sorry for my previuos question i got it just after posting my previuos mesg…its coz we want to add the noise to the signal so we need to convert it to dB … right? thnx

Reply

babar April 11, 2008 at 6:42 pm

why are we using this term 10^(-Eb_N0_dB(ii)/20) in the code to get the final signal y. why cant we write y=s+n; ???????????????

Reply

Krishna April 2, 2008 at 7:54 am

@ David: Thanks :)

Oh… were you unable to find the Matlab/Octave code? The link to the code is under the heading Simulation model.

Anyways, for BPSK it is simple. We observe the real part of the received symbol. If the real part is greater than 0 decode as +1, if the real part is less than 0 decode as -1.

Once we have the decoded symbols available, the number of differing symbols can be obtained by
nErr = size(find([ip- ipHat]),2);
Ofcourse, using find() is only one among the many different ways to compute this.

Thanks,
Krishna

Reply

David April 2, 2008 at 5:45 am

Hey,
I found theBit error curve for BPSK modulation – theory, simulation very useful. How do we demodulate , decode and compare it with the input signal

Reply

Krishna January 24, 2008 at 8:09 pm

@shareef:
Thanks. The next post is planned to be on OFDM.

Reply

mariam May 9, 2011 at 6:29 am

thanks alot or this article . it really helped me alot .
and I am waiting the ofdm article.

Reply

Krishna Sankar May 24, 2011 at 5:20 am

@mariam: The post on BER for BPSK with OFDM modulation
http://www.dsplog.com/2008/06/10/ofdm-bpsk-bit-error/

Reply

prabhat May 11, 2012 at 12:48 am

my project is to design a digital communication system using channel coding.

help me plz…
if u have matlab code and using simulink model please mail me..

Reply

Krishna Sankar May 15, 2012 at 5:56 am

@prabhat: What are the channel codes which you are planning to use?

Reply

shareef January 23, 2008 at 7:08 pm

Dear Krishna,
Your simulation and theory prgram is very usefull and helpfull.
Could you please send me the syntax matlab comand of QPSK modulation for OFDM under multipath (i.e 3 path) fading.
Very thanks in advance.
shareef

Reply

Krishna September 23, 2007 at 9:23 am

@sus: Thanks :)

Reply

Sus September 19, 2007 at 9:32 am

Thanks a lot, your BPSK BER was very useful, i got to know about the errors i made when i did the code

Reply

Krishna August 7, 2007 at 10:21 am

Thanks.
I have not checked for FSK modulation. Once I understand, hopefully will be try put together a post.

Reply

Siti naimah August 6, 2007 at 9:14 pm

Hey your BPSK theory and simulation is very useful.Do you have it for FSK modulation too?If you don’t mind please send to me. thanks.

Reply

srinivas March 5, 2009 at 7:50 am

close all
clear all
clc

N = 10^6 % number of bits or symbols
rand(‘state’,100); % initializing the rand() function
randn(‘state’,200); % initializing the randn() function

% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)
% Noise addition
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

% receiver – hard decision decoding
ipHat = real(y)>0;

% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
theoryBer1 = 0.5*erfc(sqrt(0.5.*(10.^(Eb_N0_dB/10)))); % theoretical ber

figure
semilogy(Eb_N0_dB,theoryBer,’b.-’);
hold on
axis([-3 10 10^-5 0.5])
grid on
legend(‘theory’);
xlabel(‘Eb/No, dB’);
ylabel(‘Bit Error Rate’);
title(‘Bit error probability curve for BPSK modulation’);

figure
semilogy(Eb_N0_dB,theoryBer1,’b.-’);
hold on
axis([-3 10 10^-5 0.5])
grid on
xlabel(‘Eb/No, dB’);
ylabel(‘Bit Error Rate’);
title(‘Bit error probability curve for BFSK modulation’);

In bfsk need double bit error rate to maintain the same avarage error rate in BPSK.
Feeel the difference..

Reply

Krishna Pillai March 5, 2009 at 8:34 am

@srinivas: It is not double the bit error. Infact the BER result with BFSK is 3dB poorer than BPSK. You may look @
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/

Reply

kk November 7, 2009 at 1:44 am

Hey Krishna,

I need help regarding the simulation for the fig 1 for the IEEE paper:
Xiaodi Zhang and N.C. Beaulieu, “A Closed-Form BER Expression for BPSK Using MRC in Correlated CCI and Rayleigh Fading,” IEEE Trans. Communications, vol. 55, no. 12, pp. 2249-2252, Dec. 2007.

I am getting stuck with the simulation code. Can you please give a possible MATLAB code.

kk

Reply

Krishna Sankar November 8, 2009 at 8:58 am

@kk: Sorry, I do not have time to simulate that work. Good luck.

RAO March 12, 2010 at 2:08 am

I want to change the spatial resolution in dots per inches of an image.
Do u have any code regarding this problem?
if so plz send me
regards,

Reply

Krishna Sankar March 28, 2010 at 3:54 pm

@RAO: Sorry, no

pvt April 19, 2009 at 3:25 pm

do you have this program write by c++ ?
upload for me ???

Reply

Krishna Pillai April 21, 2009 at 5:45 am

@pvt: Sorry, I do not have the c code version

Reply

Researcher August 21, 2011 at 12:59 pm

One who is interested in including his/her name in 3 research conferences in international IEEE conference should reply on email address me_researcher@yahoo.com. Both papers are related to mobile communication. Total of 3 authors list will be included in each Paper. 2 author names have already been included. Interested candidates who want to include his/her name at 3rd position will be required to pay for the registration fee.
Matlab Code as well as the full paper will be sent to the individual after acceptance of paper from the conference.
Fee submission will be through Freelancer and elance. Candidate name will be included in Paper after milestone payment is released by him/her. Milestone payment is one which is in the custody of broker (Freelancer or Elance authority) and not in the custody of either party. After the paper is accepted and the client is conformed about the acheivement, only then he will be allowed to pay. Time is short so the policy of 1st come 1st serve will be entertained.

Reply

Krishna Pillai June 20, 2009 at 8:48 am

@RAO: My replies;

1/ I have written a post on symbol error rate and bit error rate for 16-PSK.
http://www.dsplog.com/2008/03/18/symbol-error-rate-for-16psk/
http://www.dsplog.com/2008/05/18/bit-error-rate-for-16psk-modulation-using-gray-mapping/
The equation and code should be easily adapted to M-PSK case.

2/ I have not tried modeling MDPSK.

3/ I have written a post on coherent demodulation of FSK
http://www.dsplog.com/2007/08/30/bit-error-rate-for-frequency-shift-keying-with-coherent-demodulation/

Hope this helps.

Reply

Ali June 21, 2009 at 9:58 pm

please can you tell the differences in the code if we made it such that the noise is only Gaussian noise with 0 mean and No/2 variance

Reply

Krishna Pillai June 22, 2009 at 5:45 am

@Ali: We are discussing this case, no?

Reply

Ali June 22, 2009 at 6:44 pm

please can you tell me how that is discussed if you write this statement 0db variance
in this line of code

n = 1/sqrt(2)*[randn(1,N)] %+ j*randn(1,N)]; % white gaussian noise, 0dB variance

Reply

Ali June 22, 2009 at 11:31 pm

really , please can you illustrate me which part exactly in the code do this thing as the part the i see in the code is

n = 1/sqrt(2)*[randn(1,N)]; %+ j*randn(1,N)]; % white gaussian noise, 0dB variance

and you write as comment that the noise is 0 db variance

thanks for your great efforts

Reply

hemant July 19, 2009 at 9:24 am

Hi Pillai..my Mtech project is Cs-OFDMa ,here we are using LAS (smart codes),pls let me know if hav any matlab simulation for the subject mentioned.

Reply

Krishna Pillai June 23, 2009 at 4:39 am

@Ali: The 0dB variance is for complex noise (on both real and imaginary part). For BPSK we use only real part and the variance is 1/2. Agree?

Reply

Krishna Pillai July 20, 2009 at 7:11 pm

@hemant: Sorry, I have not worked on LAS. Infact, I was unaware of the acronym till I googled and found Large Area Synchronous.

Reply

anil November 7, 2009 at 1:23 pm

Hi Krishna,
I just read your answers in this website.
I am working in convolutional codes with 8psk and AWGN. I have some doubts in Iterative decoding. Can you help me.
Anil

Reply

Krishna Sankar November 8, 2009 at 9:00 am

@anil: You may ask. I will reply to the best of my knowledge

Reply

student November 10, 2009 at 9:05 pm

Hi Krishna,

I am working on a IEEE paper titled”Xiaodi Zhang and N.C. Beaulieu, “A Closed-Form BER Expression for BPSK Using MRC in Correlated CCI and Rayleigh Fading,” IEEE Trans. Communications, vol. 55, no. 12, pp. 2249-2252, Dec. 2007.”.

Since you have worked on similar field, I was hoping you can help me.

I was stuck with re creating the 1st fig from the paper.
Can you please look into it and help me.

Student

Reply

Pieter January 18, 2011 at 7:38 pm

Never mind, already found out what I did wrong… forgot to convert to dB scale :(

Reply

Krishna Sankar July 23, 2012 at 4:36 am

@khushi: in this post … :-)

Reply

Ozgeee December 27, 2012 at 5:21 am

I have to give a value to bit rate (Tb) and observe the effect of this variable on probability of error by changing it. My graph must be error versus bandwidth by accepting noise as zero. Do you have such a code? :(

Reply

Krishna Sankar December 27, 2012 at 6:09 am

@Ozgee: If the noise is zero, do not expect the bit error rate to change with bandwidth. However, i do not have such a code.

Reply

Leave a Comment

{ 7 trackbacks }

Previous post:

Next post: