# Getting the amplitudes back from fft without using ifft

I have a wave that is a sum of sines and cosines:

$$x = A\sin(\omega t + \phi_1) + B \cos(2\omega t + \phi_2) + C\sin(2\omega t + \phi_3) + D\cos(2\omega t + \phi_4).$$

Now I use fft on $x$ and get the magnitude with abs(fft(x)). How do I get $A$, $B$, $C$, and $D$ back? The reason behind this is that I am new to fft and I am trying to understand the output that Matlab fft gives back in depth. Thank you PS: I can not use ifft in any of this. Also as you can tell I am new to FFT, any of you can recommend a good source to start with ? Thank you so much for your time...

-
Are you sure you want the $B$, $C$ and $D$ terms to all have the same frequency? Presumably the frequency is meant to increase linearly? In the present formulation the six constants $B,C,D,\phi_2,\phi_3,\phi_4$ can be collapsed into two (and hence in particular can't be reconstructed from $x$ or its Fourier transform). Also it's an unnecessary complication to write some of the sinusoidals as sines and others as cosines; you can write them all as cosines and shift the $\phi_i$ accordingly. – joriki Feb 18 '13 at 18:58
Thank you for responding, I guess the sin and cos can be changed to be all either sin or cos no problem, I guess my main thing is to get the correct way of extracting info from fft output, any suggestions on how to go about this? thank you again :) – Amani Lama Feb 18 '13 at 19:02
@Amani: That question can't be separated from the issues I addressed. No comment on those? – joriki Feb 18 '13 at 19:07

Use fft(signal,M) with M a large power of 2 (e.g. 2^13). Multiply it with 2/N, where N is the number of samples in your signal: N=numel(signal). If you now plot the abs(), then the peak heights are an estimate of the amplitude of the corresponding periodic signal with that particular frequency.

An example for three signals with different amplitudes and frequencies:

clear
close all

T=20;
Ts=1/8;
t=0:Ts:T;

x = cos(2*pi*t) + .8*sin(4*pi*t) + .5*cos(6*pi*t);

M=2^13; % take a large power of 2
xh=fft(x,M);

N=numel(x);
xh_amplitudes = 2*xh/N; % amplitude estimate in fft of x

fNyq=1/Ts/2;
f=linspace(0,fNyq,M/2);

figure
plot(f,abs(xh_amplitudes(1:M/2)))
grid
xlabel f
ylabel amplitude


If you zoom in, however, you will see the peaks are not really on the actual amplitudes, but this is probably due to the leakage from the other peaks. Are these estimates good enough for you?

-
Thank you very much, I will look into this and see if I understand it completely... – Amani Lama Apr 30 '14 at 15:49