# Problems with FFT

1. Feb 16, 2005

### brian0918

This is part of my senior project. Please help! I'm trying to use a code to FFT a real, even set of data, but the results are not real and even as would be expected.

The code I'm using is availabe here (and fft.h andintl.h)

When I run RealFFT with the following 16 numbers for the Real input and nothing for the Imag input, I get these results:

Real input:
0.969647
-1.28744
0.0863155
0.19462
1.06651
0.490905
0.469052
-0.728912
-0.728912
0.469052
0.490905
1.06651
0.19462
0.0863155
-1.28744
0.969647

Real output:
2.52139
-0.37157
-2.72877
4.38382
1.74303
2.06953
0.687978
0.712455

Imag output:
1.19209e-007
0.0739102
1.13029
-2.92917
-1.74303
-3.09727
-1.66093
-3.58175

Any help? I've tried a different FFT code and the same thing happens. Help!!

2. Feb 16, 2005

### Davorak

Is there some reason you can not use matlab, mathematica, or mathcad for their built in FFT?

3. Feb 16, 2005

### brian0918

Everything has to be automated and separate, so I need to use code. This FFT is just a small part of the whole code.

Last edited: Feb 16, 2005
4. Feb 16, 2005

### FredGarvin

I did a quick FFT using Excel on your data and, short of having sign issues with the imaginary output, your numbers are exactly the same that I got.

5. Feb 16, 2005

### brian0918

The data is real and even though, isn't it? So, shouldn't the result also be real and even?

6. Feb 16, 2005

### Hurkyl

Staff Emeritus
Nope.

Though, IIRC, the imaginary parts can be computed from the real parts, so the real parts are all you actually need when the input is real.

7. Feb 16, 2005

### Atrus

It should be real only if input sequence is symmetrical around t = 0. But you assume causal sequence (with FFT), so data is shifted and phase delay is introduced, by which you get imaginary component of spectrum...

At least, that's off top of my head. Could be wrong...

8. Feb 16, 2005

### brian0918

So how would I go about inputting data so that it would be interpreted as being symmetrical around t=0? According to the text that created the code I used, it is even if the values at k and (N-k) are the same.

9. Feb 16, 2005

### Atrus

I just thought about what I wrote (I should do that BEFORE writing, right?). Well, since FFT (DFT) transform results with spectrum of periodic signal whose one period is the original sequence, it doesn't matter if the sequence is causal or not, FFT "percieves" it as periodic to + and - direction, hence the dicrete spectrum.

I've input the data in Matlab, and got the same results. Shifting the array results only in different phase frequency characteristic.

The seed of doubt in my mind is that I remember this: symmetrical real signals result in _linear_ phase characteristic, not by zero-phase...

Anyway, I'm ill and it's quite late here, so I'll try to think straight in the morning (at least, I'll try ;) )

10. Feb 17, 2005

### shmoe

I think you're mixing up the indicies somehow. If your data set is indexed starting at zero and it's even, it will look like:

$$\left[x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_7, x_6, x_5, x_ 4, x_ 3, x_2, x_1\right]$$

In this case the output will be real assuming the input is. Your data is not of this shape, so you can't expect the nice cancellation.