3
votes

I have a time varying signal (a), which I take the fft of. I need to multiply a frequency dependent weighting factor by the fft's y axis value; however if I do:

xdft = fft(a);
xdft = xdft(1:length(x)/2+1); % only retaining the positive frequencies
freq = Fs*(0:(L/2))/L; 

And plot(freq,xdft) I get a peak fft value (y axis)of ~2000 at the correct frequency of the signal. But original signal peak value (amplitude) was ~46. I need to know how the numbers relate so I can weight the fft values.

1

1 Answers

6
votes

You forgot to divide by the DFT length. Take a look at this example.

Consider that the output of fft is complex. So if you want to plot the real power spectral density you should multiply the output by its complex conjugate like this:

Pyy = xdft.*conj(xdft)/L;

Edit: For the amplitude spectrum you should do something like this:

xdft=abs(xdft/L); % same as sqrt(xdft.*conj(xdft))/L
Y=xdft(1:L/2+1); % copy half of data since the other half is redundant
Y(2:end-1) = 2*Y(2:end-1); % correct the amplitudes

Edit 2: Just wanted to point to a really great book (the best in my opinion) which explains how fourier series work (and much more) in a really easy and understandable way.

Alan V. Oppenheim, Alan S. Willsky, and S. Hamid Nawab. 1996. Signals & Systems (2nd Ed.). Prentice-Hall, Inc., Upper Saddle River, NJ, USA.