(1 votes, average: 5.00 out of 5)

# Update: Correction in Matlab code for raised cosine filter

by on May 25, 2008

Thanks to the keen observation by Mr. Phan Minh Hoang, I was notified that the Matlab/Octave scripts provided along with the topic raised cosine filtering was not behaving properly.

Reason: I was not taking care of the division by zero when creating the raised cosine filter taps.

The equation for raised cosine filter is

$g(t) = \left(\frac{sin(\pi t/T)}{\pi t/T}\right)\left(\frac{cos(\alpha \pi t/T)}{1-(2\alpha t/T)^2}\right),\mbox{ } t=-\infty \mbox{ to } +\infty$

where
$\alpha$is the excess bandwidth parameter and takes values from 0 to 1.

I was not taking care of the division by zero in the above equation. I updated the code to explictly handle the division by zero case where:

(a) $\frac{sin(\pi x)}{\pi x} =1$ for $x=0$ and

(b) $\frac{cos(\alpha \pi t/T)}{1-(2\alpha t/T)^2}=\frac{\pi}{4}$ for $|\frac{\alpha t}{T}| = \frac{1}{2}$

(Thanks to the article in RFDesign.com, The care and feeding of digital, pulse-shaping filter, Ken Gentile)

The updated posts are:

Thanks again Mr. Phan Minh Hoang.

All,
In case you find errors and inconsistencies in the article and/or simulation models, kindly let me know.
Regards,
Krishna

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.

ABHIJEET October 5, 2012 at 7:46 pm

hi, i need matlab code for ofdm transmission using pulse shaping filter like raised cosine filter
thanks

Krishna Sankar October 6, 2012 at 6:42 am

@ABHIJEET: I do not have that code, but you can refer to posts related to OFDM under
http://www.dsplog.com/category/ofdm/

But, why do wish to do raised cosine filtering with ofdm?

rasi October 8, 2009 at 7:53 am

in matlab using the inbuilt functions i generated random signal and modulated using QPSK and then transmitted adding awgn. After receiving and demodulating i m geeting zero bit error rate. Is it because of i have to use some other equations for QPSK and how can we change the frequency values and BW for the modulation. Please help me!!

Krishna Sankar October 9, 2009 at 5:39 am

@rasi: Try increasing the noise power and see whether you are getting non-zero BER. If not there might be some typos in the code. You may also refer to the post
http://www.dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/

dima January 30, 2009 at 7:13 pm

cum sa scriu cosinus la patrat de un oarecare X, in softul MATLAB

Krishna Sankar January 31, 2009 at 6:40 am

jhony May 30, 2008 at 3:32 am

can you guide me to a site or some sources from where i can get help for the code written in c++ for digital communication?

Krishna Sankar May 29, 2008 at 7:18 pm

@Jhony:
Ofcourse, we can do the simulations in C++ (or any most other programming languages). The advantage with Matlab is that it is easier to code and debug compared to C.

In Matlab, Y = A*B where A and B are matrices is a one-liner.
Imagine how many lines of code we need to write for the same operation in C?