Fft should return a series of complex numbers (can be either rectangular or polar: phase and magnitude) for a certain frequency range ...
I'm still working on expressions, but I'm betting on donuts that the arrays x and y are the real (x) and imaginary (y) components of the complex numbers that are the result of the conversion.
The absolute value of the sum of the squares of these two components should be the value of the harmonic component at each frequency (conversion to polar).
If the phase is important for your application, keep in mind that the FFT (like any phasor) can be attached to a sine or cosine. However, I believe that sine is the standard.
cm
http://www.mathworks.com/help/matlab/ref/fft.html
http://mathworld.wolfram.com/FastFourierTransform.html
Since the FFT gives a truncated approximation to an infinite series created by harmonic decomposition of a periodic signal, any periodic signal can be used to test the functionality of your code.
For example, a square wave should be easily replicated and have very well-known harmonic coefficients. The resolution of the dataset will determine the number of harmonics that you can calculate (most fft algorithms are best for a dataset whose length is equal to the power of two and is a series of integral wavelengths of the longest frequency that you want to use).
The square wave coefficients should be odd multiples of the fundamental frequency and have values ββthat vary inversely with the order of the harmonic.
http://en.wikipedia.org/wiki/Square_wave
source share