Problems with FFT: Seeking Help for Senior Project

  • Thread starter Thread starter brian0918
  • Start date Start date
  • Tags Tags
    Fft
AI Thread Summary
The discussion revolves around issues encountered while using FFT on a real, even dataset for a senior project. The user reports that the output includes unexpected imaginary components despite the input being real and even. Responses indicate that the symmetry of the input data around zero is crucial for obtaining a purely real output, and that the FFT interprets the data as periodic, which can introduce phase shifts. Suggestions include ensuring the data is structured correctly to maintain symmetry and considering the implications of data indexing. The conversation highlights the complexities of FFT and the importance of data arrangement to achieve the desired results.
brian0918
Messages
44
Reaction score
0
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 http://www.koders.com/c++/fid1C48DD8DBB45CA4B87C9A38DAFC532E793443862.aspx (and http://www.koders.com/c/fid52CE41F3A31157362D33C32AB2DBEDBBE68D78D9.aspx andhttp://www.koders.com/c/fidB64062339509A55058571EB7378153A9A2151D38.aspx?s=intl.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! :cry:
 
Physics news on Phys.org
Is there some reason you can not use matlab, mathematica, or mathcad for their built in FFT?
 
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:
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.

2.521395
-0.371567052707447-7.39092820943204E-002i
-2.72876745822043-1.13029248975726i
4.38381766777983+2.92917331814368i
1.7430325+1.7430325i
2.06953109891377+3.09727216864978i
0.687977458220434+1.66092451024274i
0.712454286013861+3.58174956841178i
0
0.712454286013851-3.58174956841177i
0.687977458220432-1.66092451024274i
2.06953109891376-3.09727216864978i
1.7430325-1.7430325i
4.38381766777983-2.92917331814369i
-2.72876745822043+1.13029248975726i
-0.371567052707448+7.39092820943208E-002i
 
The data is real and even though, isn't it? So, shouldn't the result also be real and even?
 
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.
 
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...
 
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.
 
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
brian0918 said:
According to the text that created the code I used, it is even if the values at k and (N-k) are the same.

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.
 

Similar threads

Replies
5
Views
3K
Replies
2
Views
6K
Replies
1
Views
3K
Replies
3
Views
1K
Replies
1
Views
4K
Replies
1
Views
6K
Replies
1
Views
4K
Back
Top