oscillating phases when using fft and ifft

Hi,
I noticed that I get oscillations in the phases of the fourier transform of my gaussian function and also in the inverse transform of the transform, this is illustrated in the following code:
tm=10*10^-4; dt=10^-6; t=-tm:dt:tm; t0=3*10^-5; lt=length(t); f=(-lt/2:lt/2-1)*1/(lt*dt); y=exp(-t.^2/t0.^2); ft=fftshift(fft(ifftshift(y))); y2=ifftshift(ifft(fftshift(ft)));
figure subplot(3,2,1); plot(t,y); title('Initial time profile') subplot(3,2,2); plot(t,phase(y)); title('Initial time phase'); subplot(3,2,3); plot(f,abs(ft)); title('Fourier transform, magnitude') subplot(3,2,4); plot(f,unwrap(phase(ft))); title('Fourier transform, phase') subplot(3,2,5); plot(t,abs(y2)); title('Second time profile') subplot(3,2,6); plot(t,unwrap(phase(y2))); title('Second time phase')
I'm wondering if there's any way to get rid of these or if I need to use some sort of filter? In my real program, I need to be able to affect the spectral content of the fourier transform before I invert it back to time space.
Thanks in advance Robert

回答 (2 件)

Cindy Solomon
Cindy Solomon 2015 年 5 月 6 日
編集済み: Cindy Solomon 2015 年 5 月 6 日

0 投票

Hi Robert,
Is there a reason you're defining ft and y2 by first performing fftshift or ifftshift on those signals? These functions are intended to shift the zero-frequency component to the center of the spectrum. For example, you would use fftshift after FFT if you want to center the plot and view it as a 2-sided spectrum with the axis -Fs/2 to +Fs/2.
In addition, the values that you are calculating are not symmetric, which leads to phase offsets. A signal with non-zero phase means that your frequency amplitudes will oscillate.
Hope this helps!
Robert
Robert 2015 年 5 月 8 日
編集済み: Robert 2015 年 5 月 8 日

0 投票

Hi Cindy,
The use of fftshift after taking the fft is actually not the correct way of doing it (if you're starting with a function centered at t=0), even though it's the most commonly used one (and if you're not interested in the phases you won't notice much of a difference), the reason for this can be found at: http://www.mathworks.com/matlabcentral/newsreader/view_thread/285244
however, I actually messed the ordering of the fftshift and ifftshift up in the inverse transform in the code i posted above, it should be like this:
tm=10*10^-4; dt=10^-6; t=-tm:dt:tm; t0=3*10^-5; lt=length(t); f=(-lt/2:lt/2-1)*1/(lt*dt); y=exp(-t.^2/t0.^2); ft=fftshift(fft(ifftshift(y))); y2=fftshift(ifft(ifftshift(ft)));
figure subplot(3,2,1); plot(t,y); title('Initial time profile') subplot(3,2,2); plot(t,phase(y)); title('Initial time phase'); subplot(3,2,3); plot(f,abs(ft)); title('Fourier transform, magnitude') subplot(3,2,4); plot(f,unwrap(phase(ft))); title('Fourier transform, phase') subplot(3,2,5); plot(t,abs(y2)); title('Second time profile') subplot(3,2,6); plot(t,unwrap(phase(y2))); title('Second time phase')
Nevertheless, the oscillations are still present and they will also be present if I use the more common way of doing it, i.e. ifft(fft(y)). So the root of the oscillations must be something else.
Cheers
Robert

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2015 年 5 月 4 日

編集済み:

2015 年 5 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by