LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT phase spectrum differs from theory?

In order to understand how FFT approximates the continuous-time fourier transform, I did this exercise.

 

I took the signal x(t) = exp(-t), t >=0.

Theory tells me that its Fourier transform is

X(f) = 1/(1+j*2*pi*f)

thus the amplitude spectrum is

1/sqrt(1+(2*pi*f)^2)

and the phase spectrum is

-atan(2*pi*f).

In the attached VI, just for fun, I plotted X(f) in 3 ways:

  1. Amplitude and phase according to the analytical approach;
  2. Amplitude and phase according to the FFT.vi node;
  3. Amplitude and phase according to a "manual" calculation (that approximates the fourier integral with a finite sum);

 

Amplitude is always the same.

As for phase, Points 2 and 3 give exactly the same result, which is different from point 1.

 

I know this is more of a math-related problem rather than a LabVIEW-related one, but I'm really curious about it and maybe somebody has the answer?

 

 

 

 

 

0 Kudos
Message 1 of 10
(4,915 Views)
No time to whip up an example and long explanation, but consider the following which I consider to be the most overlooked aspect of approximating a continuous Fourier Transform with an FFT.  The continuous FT is an infinite integral, it is easy to imagine a signal which extends for infinite time, but in the discrete case you have to have a finite time.  This can still be thought of in terms of a continuous FT, but you have two additional steps.  First, you are sampling in time which means you are multiplying by a comb of delta functions.  This doesn't do much that is particularly interesting.  The second step is to enforce a finite approximation, this means you are multiplying your imaginary signal which extends for infinite time by a finite width box.  As you see in your textbook, the FT of a product is a convolution, so you are convolving your expected FT with the FT of the box which is not simple.  Take this into account and you'll likely see that the result will meet your revised expectations.
Message 2 of 10
(4,902 Views)

Hi Darin, thanks for the reply but I don't think it fits, for 4 reasons:

 

  1. Why is the amplitude perfectly approximated and only the phase is not?
  2. The domain of my signal is taken in a way that "it is practically zero" outside of its domain (exp(-t) for t>= 14 is 1E-6 or less)
  3. I did the same exercise for a finite-time signal and there was the same phase problem.
  4. According to your explanation, the longer the time-signal domain, the better the approximation. But nothing changes (I tried that out.)

 

I think you haven't looked at the attached example so I'm putting a picture, this time (it's quicker to look at): http://img707.imageshack.us/img707/6245/fftdoubt.png

 

Basically, the phase computed by the FFT is always sloped. Its analytical counterpart is not. What do you guys think?

 

Message Edited by Ale83 on 03-22-2010 12:18 PM
Message Edited by Ale83 on 03-22-2010 12:20 PM
Message Edited by Ale83 on 03-22-2010 12:21 PM
0 Kudos
Message 3 of 10
(4,892 Views)

Ale83 wrote:

Hi Darin, thanks for the reply but I don't think it fits, for 4 reasons:

 

  1. Why is the amplitude perfectly approximated and only the phase is not?
  2. The domain of my signal is taken in a way that "it is practically zero" outside of its domain (exp(-t) for t>= 14 is 1E-6 or less)
  3. I did the same exercise for a finite-time signal and there was the same phase problem.
  4. According to your explanation, the longer the time-signal domain, the better the approximation. But nothing changes (I tried that out.)

 

I think you haven't looked at the attached example so I'm putting a picture, this time (it's quicker to look at): http://img707.imageshack.us/img707/6245/fftdoubt.png

 




Although it was not necessary I did look at the example program and I do not have Mathscript as of LV9.  I could tell from your description that you did not fully understand the difference between the Discrete Time FT (as approximated by the FFT) and the continuous time FFT.   If you were to generate the continuous time analog of your sampled signal you will find that after you sample, window and periodically extend the signal that your results should match.  Your textbook should describe this process.

 

In your simple case, you do not even need the FFT to find the DTFT.  If you write out the sum, you will find a geometric series, here is the result I get for the DTFT, you can test on your data and if you find the result matches the FFT result then you know the FFT is doing its job (which is to approximate the DTFT).  No guarantees against math errors since this is back of the envelope.

 

FiniteFT2.png

 

As to question #1, the fact that the results match at f=0 are most likely a vindication of Parseval's theorem.  As you see, it doesn't match at other frequencies.  2,3,4 are all explained by periodic extension.

Message 4 of 10
(4,865 Views)

Thank you for the answer, Darin. You are right that the periodic extension is key and I tried to sort out things from that perspective and it explains many things. However I still can't get the result I'd expect from applying the textbook stuff. Maybe I'm still missing something. This is what I think I should get:

 

Continuous time signal: x(t) = exp(-t), t>=0 ---> Theory tells me that X(f) = 1/(1+j*2*pi*f)

Sampled signal: p[n] = x(nT) = exp(-nT), n = 0, 1, 2, ...  ---> Theory tells me that P(f) = 1/(1-exp(-j*2*pi*f*T-1))

 

 

As far as I understand, since sampling in time -> periodicization in frequency, it should be true that P(f) = (1/T) * sum_k X(f - k/T) but it is not the case, if I try to plot in amplitude and phase the two ways of obtaining P(f).What am I doing wrong?

 

 

 

 

0 Kudos
Message 5 of 10
(4,816 Views)

Sorry, as for the sampled signal transform there was a little mistake in my last post. Here's the correct form

 

Sampled signal: p[n] = x(nT) = exp(-nT), n = 0, 1, 2, ...  ---> Theory tells me that P(f) = 1/(1-exp(-j*2*pi*f*T-T))

 

 

The quantity P(f) = (1/T) * sum_k X(f - k/T) is true concerning amplitude spectra, but slightly different concerning phase spectra.

If I check it in terms of real and imaginary part, they seem to agree very well.

0 Kudos
Message 6 of 10
(4,772 Views)

 I meet the same problem like you .But even I use fft.vi and take the signal x(t) =exp(-t), t>=0 ,I find the  phase
spectrum is still different from theory.If you replace the signal x(t) =exp(-t) into gauss pulse f(t)=exp(-(t/a)^2),
 you will find the result is the same ,the phase spectrum  is also different from theory.Do you find answer now?

0 Kudos
Message 7 of 10
(4,135 Views)

yes, I figured that out. Here's the thing:

 

 

You have your continous time signal x(t), ok? Great. Then you sample it and get a sequence x[n].

 

They key point is, in that sequence the sampling-time information is lost. Samples are spaced by a dimensionless unit (x[0], x[1], x[2], ....).

 

DTFT doesnt care what the sampling time is. That will be your business, but later!

 

 

 

Let's have a look at our example. You have exp(-t) and sample it to get exp[-n]. Its DTFT is X(w) = 1/(1-exp (-1-j*w) ) where w is the "dimensionless" frequency, it is in radians, not Hz, and its base period is [-pi, pi]

 

The phase of X(w) in theory is exactly what the FFT.vi plots.

 

Don't forget that FFT is only a way of implementing DTFT, but they are the same thing 🙂

 

The "actual" frequency in Hertz will be W = w/T, where T is your original sampling time. It simply de-normalizes the w axis and gives it a unit of measurement. It is nothing more than a rescaling, the spectrum shape (amplitude and phase) does not change.

 

 

Clear?

0 Kudos
Message 8 of 10
(4,128 Views)

My point is, the phase spectrum of your continous-time signal and the phase spectrum of your sampled signal already ARE different.

 

The FFT.vi is an implementation of that and shows nothing else than the theory behind it.

0 Kudos
Message 9 of 10
(4,123 Views)

Hello,

 

Could you please explain it again I do not get your point.

I have also a similar problem that the magnitude in the amplitude spectra delivers pretty accurate results and the phase from the phase spectra shows me wrong values by using an FFT of an incoming square signal and I don´t know why.

 

Best regards

Alex

0 Kudos
Message 10 of 10
(3,067 Views)