Using fft (Fast Fourier Transform)
Using fft (Fast Fourier Transform)
(OP)
Hi.
In the example on how to use fft, once they have the signal, they do this:
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
Meaning that they get the next power of 2 from length of y (the signal), and then they calculate the NFFT-points fft, to then divide it by L (length of y).
¿Can you tell me why they do that?
What I'm trying to do is capture a sound signal and then with the fft get the frequency of that signal.
Thank you!
In the example on how to use fft, once they have the signal, they do this:
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
Meaning that they get the next power of 2 from length of y (the signal), and then they calculate the NFFT-points fft, to then divide it by L (length of y).
¿Can you tell me why they do that?
What I'm trying to do is capture a sound signal and then with the fft get the frequency of that signal.
Thank you!
RE: Using fft (Fast Fourier Transform)
Personally I don't like it and don't do it.
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Using fft (Fast Fourier Transform)
The zero padding as Greg says doesn't hurt, in fact gives finer "frequency resolution"... sort of.
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
RE: Using fft (Fast Fourier Transform)
The thing is that I capture the sound of a guitar, let's say an 'A', and after doing the fft and plot the result, I can see a peak where the main frequency should be, but it shows a number that is not supposed to be the one for 'A' (let's say I get a peak on 29, and the frequency's supposed to be 110), so I was looking for the answer on that business with the n-point fft...
¿You reckon what am I doing wrong?
Thanks again!
RE: Using fft (Fast Fourier Transform)
in the example, after calculatin the fft with Y=fft(y,NFFT)/L , to show the graph (and get the frequency from there), they do:
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1);
so maybe I should do something like that (not exactly that though, I guess, cos it gives me that wrong frequency I told you about), but I'm not really sure why they do the 2*abs(Y(1:NFFT/2+1). The only thing I kinda get is that they represent half of the signal only cos you have all the info you need there.
RE: Using fft (Fast Fourier Transform)
- Steve
RE: Using fft (Fast Fourier Transform)
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Using fft (Fast Fourier Transform)
do a search. I recall vividly posting an example FFT script.
Fe
RE: Using fft (Fast Fourier Transform)
I'll do a search around the forum to look for those fft examples, and if I'm still confused about it, I'll post the code I wrote so you can check it. :)
RE: Using fft (Fast Fourier Transform)
Cheers!