Trying to understand the MATLAB fft example and how to determine amplitudes of frequencies?

2 views (last 30 days)
Hey
I have made a plot of a signal using the MATLAB fft example:
L=length(channel1);
NFFT=2^nextpow2(L);
Y=fft(channel1,NFFT)/L;
f=fs/2*linspace(0,1,NFFT/2+1);
figure(3)
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Amplitude spectrum')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
Questions:
1. I don't understand the values of Y: Why is it necessary to expand the vector to the length of the NFFT? And why divide by L?
2. In determining the frequency axis. The code generates a vector with length 32769, but the frequencies only goes to the nyquist frequency: fs/2=22050. Some of the frequencies are represented more than once along the frequency axis, why is that?
3. As far as I understand. The Amplitude of a frequency determines how loud the sound of the frequency is heard in the signal. Is it possible to get the amplitudes of the 10 most significant frequencies from this plot?

Accepted Answer

dpb
dpb on 16 Aug 2015
  1. It's not mandatory but FFT is fastest for powers of 2. That used to be much more of a significant issue than now w/ the advent of much faster processors, but the "tradition" lives on...but, since you used the example which does compute the next power of 2 and augments the signal to that length, then that's the length being used and hence the normalization.
  2. The TMW Matlab implementation of fft returns the two-sided fft with the DC component in the middle; negative frequencies to the left, positive to the right (+ indices offset) from that point. Here again, it's just convention as to which to use; the 2-sided is more general.
  3. Use findpeaks
  11 Comments
dpb
dpb on 19 Aug 2015
"...couldn't it also be, that the division with length L comes from the equations stated at the beginning of the example?"
Of course, the normalization is based on the particular definition of the FFT implemented; there are various implementations that may or may not compensate internally but if you want output that represents the magnitude of the input in the same scale it's got to get normalized at some point. Again I refer you to Brigham or some other text on digital signal processing (altho I understand there are competent tutorials available on the web now, I'm of an age preceding that circumstance so I don't know of any in particular to recommend, sorry).

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!