Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm having trouble to understand what's going on with my FFT. Given a number of sinusoidal points, I need to fit them into a sine function. That is, I need to know A, B, C and D from y = A·sin(B·t+C)+D.

The way I intended to do it was by performing the FFT -> D (the offset) would be the amplitude at 0 Hz, B the frequency where the FFT amplitude is maximum, so I can also know A at that point.

I use C# (.NET) together with the Exocortex.DSP.v1 library. I did my own graphic library. You can download the .exe from here -> http://openelectronicdesigns.com/files/public/myFFT.zip[^].

This is just a program to show my problem. I generate a time signal, then calculate the FFT, and represent the complex number in the Complex plot. As you can see when you uncheck the "FFT Windowing" and set the frequency to 10 (10 cycles over 1024 points), you can change the phase, and the phasor at the Complex plot changes according to it. The phase is correct in that case.

Here the problem comes. If you change the frequency, let's say at 10.25Hz, the phase also changes, and that's what I don't understand. I can only calculate the phase when I have a complete number of cycles inside the 1024 points of the FFT. Initially I thought it was because of the discontinuity from the last to the initial point, and that's why I added the FFT Windowing option. But it makes no major difference...

Anyone could please tell me what am I doing wrong? I think it might be a conceptual problem rather than a programmatic one, but there are lots of intelligent people around here ;)

Thank you!
Posted

1 solution

I see the problem now, I was watching it from the wrong way... The FFT of a sine with a non complete number of cycles is the sum of lots of sines with different phases and amplitudes, that's why the complex plot is shown that way...

So, the question is: can I make any kind of calculation with the complex data get A,B,C and D, assuming that the input is a sine wave?

Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900