Problems with FFT: Seeking Help for Senior Project

  • Thread starter brian0918
  • Start date
  • Tags
    Fft
In summary, the conversation is about using a code to FFT a real, even set of data but the results are not as expected. The code being used is available online and has been tried with different data sets, but the results are still not accurate. The conversation also discusses the possibility of using Matlab or other software for FFT, but the need for automation and separate code is a limiting factor. The issue of causality and symmetry in the input data is also brought up. In the end, it is determined that the data being used is not symmetrical around t=0, leading to the unexpected results.
  • #1
brian0918
44
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
  • #2
Is there some reason you can not use matlab, mathematica, or mathcad for their built in FFT?
 
  • #3
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:
  • #4
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
 
  • #5
The data is real and even though, isn't it? So, shouldn't the result also be real and even?
 
  • #6
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
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
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
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:

[tex]\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][/tex]

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.
 

Related to Problems with FFT: Seeking Help for Senior Project

1. What is FFT and why is it important in a senior project?

FFT stands for Fast Fourier Transform and it is a mathematical algorithm used for signal processing and data analysis. It is important in a senior project because it allows for the analysis of large amounts of data in a efficient and accurate manner.

2. What are some common problems encountered when using FFT in a senior project?

Some common problems with FFT include incorrect input data, incorrect parameters, and computational errors. These can lead to inaccurate results and must be carefully addressed in order to obtain reliable data.

3. How can I seek help for FFT-related problems in my senior project?

There are several ways to seek help for FFT problems in your senior project. You can consult with your project advisor or other faculty members with expertise in signal processing. Additionally, online resources such as forums and tutorials can also provide assistance.

4. Are there any alternative methods to FFT that can be used in a senior project?

Yes, there are alternative methods to FFT that can be used in a senior project. Some examples include Discrete Fourier Transform (DFT), Discrete Cosine Transform (DCT), and Wavelet Transform. These methods may be more suitable for certain types of data and can provide similar results to FFT.

5. How can I ensure the accuracy of my FFT results in my senior project?

To ensure the accuracy of your FFT results, it is important to carefully validate the input data and parameters used in the analysis. It is also helpful to compare the results with other methods or software to verify consistency. Additionally, performing multiple iterations or trials can also help to identify and eliminate any potential errors.

Similar threads

  • Programming and Computer Science
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
3
Views
868
  • Electrical Engineering
Replies
2
Views
5K
Replies
2
Views
3K
  • Electrical Engineering
Replies
1
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
Replies
9
Views
1K
  • Differential Equations
Replies
1
Views
2K
Back
Top