FFT For Spectral Analysis
FFT For Spectral Analysis
fft
Fast Fourier transform
collapse all in page
Syntax
Y = fft(X)
example
Y = fft(X,n)
example
Y = fft(X,n,dim)
example
Description
exa
Y = fft(X)computes the discrete Fourier transform (DFT)
of X using a fast Fourier transform (FFT) algorithm.
If X is a vector, then fft(X) returns the Fourier transform of the
vector.
If X is a matrix, then fft(X) treats the columns of X as vectors and
returns the Fourier transform of each column.
If X is a multidimensional array, then fft(X) treats the values
along the first array dimension whose size does not equal 1 as
vectors and returns the Fourier transform of each vector.
exa
returns the n-point DFT. If no value is specified, Y is
Y = fft(X,n)
the same size as X.
If X is a vector and the length of X is less than n, then X is padded
with trailing zeros to length n.
If X is a vector and the length of X is greater than n, then X is
truncated to length n.
If X is a matrix, then each column is treated as in the vector
case.
If X is a multidimensional array, then the first array dimension
whose size does not equal 1 is treated as in the vector case.
exa
Y = fft(X,n,dim)returns the Fourier transform along the
dimension dim. For example, if X is a matrix,
then fft(X,n,2) returns the n-point Fourier transform of each row.
Examples
se Fourier transforms to find the frequency components of a
signal buried in noise.
Specify the parameters of a signal with a sampling frequency of
1 kHz and a signal duration of 1 second.
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and
a 120 Hz sinusoid of amplitude 1.
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
Corrupt the signal with zero-mean white noise with a variance of
4.
X = S + 2*randn(size(t));
Plot the noisy signal in the time domain. It is difficult to identify
the frequency components by looking at the signal X(t).
plot(1000*t(1:50),X(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('t (milliseconds)')
ylabel('X(t)')