FFT output is a frequency vector that can apply to this function?

In the Description of fft, it said "If X is a vector, then fft(X) returns the Fourier transform of the vector.". If I read a wav file into matlab,
x = wavread(wavFile);
xF = fft(x)
What kind of thing xF is? Is it a vector, matrix or multidimensional array? If I would like to implement melfilter function, can I use xF as the frequency vector?
If I cant, how can I create a frequency vector from the wav file I read?
Thanks

 Risposta accettata

Your ‘xF’ variable contains the complex Fourier transform of ‘x’. For a vector, it take the Fourier Transform of the vector For a matrix, it takes the Fourier transform column-wise (along the columns). Since your ‘x’ is most likely a (Nx2) matrix, (one column for each channel), ‘xF’ will have the same dimensions.
I still prefer the R2015a documentation for fft (link), because the code between the first (top) two plot figures is descriptive and easy to understand.

4 Commenti

So is that a frequency vector? If I want a frequency vector, what can I do with x? Thanks
That documentation has the code to create the frequency vector and plot the single-sided Fourier transform as a funciton of frequency.
Specifically, if ‘Fs’ is your sampling frequency:
Fv = linspace(0, 1, fix(length(xF)/2)+1)*Fs/2; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, abs(xF(Iv))*2)
grid
Note This is UNTESTED CODE. However, I’ve written versions of it so often that I am certain it will work. One potential problem is if you have a large constant offset (also known as a d-c offset) and much smaller frequency components, making them difficult to see. The easiest way to deal with that is to replace the plot call with semilogy.
Is that going to be the same if I cut the x frame to frame? lets say x(1:320) x(321:640) . . .
It would be. Cutting it frame-to-frame would significantly reduce the frequency resolution, unless you zero-pad your vector by using a relative large (and constant) value for the length of the Fourier transform (noted as ‘NFFT’ in the documentation).
I’m not certain what you’re doing with your signal. If you want to do a time-frequency analysis of it, and if you have the Signal Processing Toolbox, see the spectrogram function. It will probably do the time-frequency analysis much more easily than writing your own code.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by