Why frequency domain signal is not reconstructed using ifft followed by fft?

22 visualizzazioni (ultimi 30 giorni)
I was checking if I start with a frequency domain signal, find its inverse Fourier transform (using ifft), then get the function back using Fourier transform (using fft). The final result I am getting is very strange: the time domain signal (after ifft) looks perfect but the real (or imaginary) part of frequency domain signal (after fft of the time domain signal) looks very different from the original frequency domain signal I started with (it is showing oscillations like time domain signal) although the absolute part looks fine. Here it is:
%-----------------------------------
w1 = linspace(0,1000,1024);
w1 = w1;
W = 10;
w0 = 100;
N = length(w1);
dw = mean(diff(w1));
Y1 = exp(-((w1-w0)/W).^2);
%IFFT
y1 = ifft(Y1);
y1 = ifftshift(y1);
t1 = t1 = (-N/2 : N/2 - 1)/dw;
%FFT
Y2 = fft(y1);
Y2 = fftshift(Y2);
w2 = (-N/2 : N/2 - 1)*dw;
%PLOTS
subplot (1,3,1); %plot of the original frequency domain signal I started with
plot (w1,Y1)
xlim ([-200 200]);
axis square;
subplot (1,3,2);
plot (t1, real(y1)) %plot of the time domain signal
xlim ([-100 100]);
axis square;
subplot (1,3,3);
plot (w2,real(Y2)) %plot of the real part of frequency domain signal
hold all
plot (w2,abs(Y2)) %plot of the absolute part of frequency domain signal
xlim ([-200 200]);
axis square;
%-----------------------------------
Will highly appreciate if anyone can resolve this issue. Thanks.

Risposta accettata

Arijit De
Arijit De il 18 Lug 2018
Modificato: Arijit De il 18 Lug 2018
Ok, figured it out: ifftshift (or fftshift) is only for plotting, so before doing the fft (or ifft) the complex function has to be regenerated by ifftshift (or fftshift) - here is the code:
%-----------------------------------
w1 = linspace(0,1000,1024);
w1 = w1;
W = 10;
w0 = 100;
N = length(w1);
dw = mean(diff(w1));
Y1 = -exp(-((w1-w0)/W).^2);
%PLOT
subplot (1,3,1); %plot of the original frequency domain signal I started with
plot (w1,Y1)
xlim ([-200 200]);
axis square;
%IFFT
y1 = ifft(Y1);
y1 = ifftshift(y1); %this is only for plotting
t1 = (-N/2 : N/2 - 1)/dw;
%PLOT
subplot (1,3,2);
plot (t1, real(y1)) %plot of the time domain signal
xlim ([-100 100]);
axis square;
%FFT
y1 = ifftshift(y1); %this is crucial
Y2 = fft(y1);
Y2 = fftshift(Y2); %this is only for plotting
w2 = (-N/2 : N/2 - 1)*dw;
%PLOT
subplot (1,3,3);
plot (w2,real(Y2)) %plot of the real part of frequency domain signal
xlim ([-200 200]);
axis square;
%-----------------------------------

Più risposte (1)

Constantino Carlos Reyes-Aldasoro
The issue here is that when you apply the Fourier Transform you will have a real and an imaginary part (except in some special cases) and your signal is formed by both parts. For a more accurate representation of your signal try plotting like this:
plot3(w2,real(Y2),imag(Y2))
and you will see the real and imaginary axes. Now, if you want to "understand" better your signal, the magnitude (abs) is a more accurate representation of what you are expecting and thus your plot is showing the envelope of the real signal is more or less what you expected.
There are other issues due to the number of points (2^n is always a good choice) and the negative and positive parts of the Transform.
Hope this helps.
  1 Commento
Arijit De
Arijit De il 18 Lug 2018
Modificato: Arijit De il 18 Lug 2018
If one starts with a time domain signal and includes a phase shift, after fft envelope of only the real/imaginary part of the frequency domain signal has the negative magnitude - envelope of the absolute part does not have any negative magnitude - so it is necessary to get amplitude of the real/imaginary part rather than amplitude of the absolute part.
The number of points in the code is already chosen as 1,024 (2^10).

Accedi per commentare.

Tag

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by