# Discrete Fourier Transform in MATLAB

1. Mar 11, 2012

### SamuraiJack

Hello all, first time here and I have really silly problem...
I am working on something in MATLAB, in which I have to make discrete fourier transform
of gaussian distributed variable. i.e. array of numbers which are taken from f(x)~exp(-x^2). I know that when you fourier transform it with integral you get the same distribution in k-space. i.e. f(k)~exp(-k^2), but in the discrete transform I get the distribution something like f(k)~sin(k)exp(-k^2)...

help!! someone... why?

Thnx,

The Samurai.

2. Mar 12, 2012

### marcusl

It's hard to know what's going on from your vague description. Did you use fftshift after the fft?

3. Mar 13, 2012

### Delta Kilo

Did you look at the modulus or just the real part? Hint: f(x)-> F(y); f(x-a) -> ???

4. Mar 13, 2012

### SamuraiJack

Hello marcusl, thank you for your response. Let me change the question since it doesn't really matter if it is in matlab or not. If you are doing fourier transform from x to k space to a gaussian f(x)~exp(-x^2), you get f(k)~exp(-k^2). However, doing discrete fourier transform to set of values in the x space which are distributed as f(x)~exp(-x^2), you get set of values that are distributed as f(k)~sin(k)exp(-k^2). I thought that in the limit Delta x -> 0, the transforms should be almost the same but they are clearly different.
WHY?

Delta Kilo, I also checked modulus. But actually the real part in negligible. (which is also a problem, because in this transform, the imaginary part should vanish, there is a mysterious pi/2 phase shift. How ever, with this problem I can live)

thanks again.

5. Mar 13, 2012

### Hassan2

Hi SamuraiJack,

I havent worked with Matlab for ages but I remember a few things:

FFT is for perioidc sequences and Matlab makes your sequence periodic to calculate the FFT. When you give the sequance withing an interval, Matlab assumes that this is only one period if a periodic data. When the length of the sequence is infinite, you get the expected fourier sequence.

Since your data length is limited, it is equal to your Gaussian sequence multiplied by a square function. As we know the the FFT for this mutiplication is the convolution of their FFT, which is the convolution of a sinc function and a Gaussian one.This is what your current result is.

6. Mar 18, 2012

### SamuraiJack

Hello Hasan,
Although I watched it one week later... This is exactly the answer I was looking for.

Thanks.