How can I do Fourier transform of a function using FFT , keeping information of both the amplitude and phase ??

1 view (last 30 days)
In general when FFT is used to evaluate the fourier transform, only the absolute value is plotted. The phase after performing the FFT turns out to be oscillatory. I am looking for a way to use FFT on various functions to evaluate the fourier transform.
E.g: fourier transform of the function f(x)=(x-1)^2 Exp(-x^2) for simplicity.

Answers (1)

Youssef  Khmou
Youssef Khmou on 6 Feb 2013
Hi, Avinash, you can use this function :
function z=Fast_Fourier_Transform(x,nfft)
N=length(x);
z=zeros(1,nfft);
Sum=0;
for k=1:nfft
for jj=1:N
Sum=Sum+x(jj)*exp(-2*pi*j*(jj-1)*(k-1)/nfft);
end
z(k)=Sum;
Sum=0;% Reset
end
  2 Comments
Avinash Rustagi
Avinash Rustagi on 6 Feb 2013
I was thinking more along the lines of getting to use the built-in functions because ultimately I need to evaluate the transforms of two variable functions. Using "for" loops won't be a very good idea for a large number of data points.
I need to get the fourier transform of f(x,y) and the sampling is done at very small spacings to give me a large number of data points.
I have tried something which works but cannot justify why ?
If "f" is the function and "g" is the fourier transform, I get very good results if I use
g=fftshift(fft(fftshift(f))); Note: the extra "fftshift" before taking the "fft". Using this chain of command , I do not have to worry about the phase. Everything fits in.
Youssef  Khmou
Youssef Khmou on 6 Feb 2013
Edited: Youssef Khmou on 6 Feb 2013
in the submission, the fft built-in is the core, but the functions computes nfft and give exact frequencies by adjusting frequency axis and amplitudes .
Ok anyway we wait for better answer .

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!