DSPRelated.com
Forums

FFT in Matlab

Started by ngweelee February 17, 2002
Hi guys,

Can anyone please tell me how to perform fft on an array produced by
matlab function 'wavread' and the result plotted on a figure to get
the pitch of the wav file?

Any help is greatly appreciated.

Thanks




Hi,
FFT in matlab can be done using direct FFT function.

let us say k is an array of size N
then call fft directly. using

fftk= fft(k,N);

Once you got fft in the array fftk, you can easily plot isnt it?
For more info, you can see the FFT help from MATLAB.

%FFT Discrete Fourier transform.
% FFT(X) is the discrete Fourier transform (DFT) of vector X. If the
% length of X is a power of two, a fast radix-2 fast-Fourier
% transform algorithm is used. If the length of X is not a
% power of two, a slower non-power-of-two algorithm is employed.
% For matrices, the FFT operation is applied to each column.
% For N-D arrays, the FFT operation operates on the first
% non-singleton dimension.
%
% FFT(X,N) is the N-point FFT, padded with zeros if X has less
% than N points and truncated if it has more.
%
% FFT(X,[],DIM) or FFT(X,N,DIM) applies the FFT operation across the
% dimension DIM.
%
% For length N input vector x, the DFT is a length N vector X,
% with elements
% N
% X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N.
% n=1
% The inverse DFT (computed by IFFT) is given by
% N
% x(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N.
% k=1
%
% The relationship between the DFT and the Fourier coefficients a and b in
% N/2
% x(n) = a0 + sum
a(k)*cos(2*pi*k*t(n)/(N*dt))+b(k)*sin(2*pi*k*t(n)/(N*dt))
% k=1
% is
% a0 = 2*X(1)/N, a(k) = 2*real(X(k+1))/N, b(k) = 2*imag(X(k+1))/N,
% where x is a length N discrete signal sampled at times t with spacing
dt.

Regards,
Sridhar

-----Original Message-----
From: ngweelee [mailto:]
Sent: Monday, February 18, 2002 2:39 AM
To:
Subject: [matlab] FFT in Matlab Hi guys,

Can anyone please tell me how to perform fft on an array produced by
matlab function 'wavread' and the result plotted on a figure to get
the pitch of the wav file?

Any help is greatly appreciated.

Thanks

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you
want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3

">http://docs.yahoo.com/info/terms/