# How to get coefficients for sine/cosine function from complex FFT?

I'm working on a control system that measures the movement of a vibrating robot arm. Because there is some deadtime, I need to look into the future of the somewhat noisy signal. My idea was to use the frequencies in the sampled signal and produce a fourier function that could be used for extrapolation.

My question: I already have the FFT of the signal vector (containing 60-100 values e.g.) and can see the main frequencies in the amplitude spectrum. Now I want to have a function f(t) which fits to the signal, removes some noise, and can be used to predict the near future of the signal. How do I calculate the coefficients for the sine/cosine functions out of the complex FFT data?

• This may be what you want: dsp.stackexchange.com/questions/101/… Oct 29, 2011 at 13:24
• Are you looking for help with your MATLAB code? If so, then Stack Overflow is the right place for you. Signal Processing is more for conceptual questions, algorithms and language agnostic solutions Oct 29, 2011 at 19:47

This is a no brainer for anyone who's studied signal processing (Im wondering why its been so long since its been answered)

The Fourier Transform itself is a function that tells you what sinusoid do you need to add together to create this continuous signal. (Its like the Fourier series for more complex signals)

the FFT algorithm gives you COMPLEX coefficients (a+bj) (where j is the imaginary number... it looks like and i but backwards....)

calculate the magnitude of each coefficient A(n) = sqrt(a(n)^2 + b(n)^2) calculate the phase of each coefficient phi(n) = inverse_tan(b(n)/a(n)); (remember to use atan2 so that it results in the correct quadrant)

now remember based on your sampling rate each coeff represents a "bin" of frequencies, however you should think of them as evenly distributed frequencies:

So if you have N bins each frequency_bin they represent is f = Fs/(2*N)

$$f(x) = \Sigma^N_0 A(n)*cos(2*\pi*f(n) + \phi(n))$$