Fourier transform of a continuous non-periodic function in matlab

2.1k Views Asked by At

I would like to use matlab to find an Fourier transfom of a function which is known only on a grid.

As an example I take the function f(x) = exp (-x^2), which Fourier transform is known and is equal to g(y) = pi^(1/2)*exp(-y^2/4);

For the fourier transform in matlab I use fft() and apparently I am doing something wrong because the result is weird.

x = -10:0.01:10; y = exp(-x.^2); plot(x, fft(y));

fft(y)

Where am I wrong?

1

There are 1 best solutions below

2
On BEST ANSWER

You're doing nothing wrong except that the variable x is not the appropriate variable to plot the spectrum, but this does not matter much here. The problem is that your function only has components at very low frequencies which you hardly see in your full-range plot. If you swap the right and the left half of the spectrum and plot just the range around zero frequency you see what you would expect to see:

Y1=[Y(1952:2001),Y(1:50)];
plot(abs(Y1))

enter image description here