0% found this document useful (0 votes)
7 views3 pages

FFT For Spectral Analysis

This document discusses the use of Fast Fourier Transform (FFT) for spectral analysis, particularly in identifying frequency components in noisy signals. It provides an example of generating a time-domain signal composed of sine waves at 50 Hz and 120 Hz, and demonstrates how to add noise to this signal. The document also outlines the syntax and functionality of the FFT function in various contexts, including vectors and matrices.

Uploaded by

Okok Okok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

FFT For Spectral Analysis

This document discusses the use of Fast Fourier Transform (FFT) for spectral analysis, particularly in identifying frequency components in noisy signals. It provides an example of generating a time-domain signal composed of sine waves at 50 Hz and 120 Hz, and demonstrates how to add noise to this signal. The document also outlines the syntax and functionality of the FFT function in various contexts, including vectors and matrices.

Uploaded by

Okok Okok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

FFT for Spectral Analysis

Open Live Script


This example shows the use of the FFT function for spectral
analysis. A common use of FFT's is to find the frequency
components of a signal buried in a noisy time domain signal.
First create some data. Consider data sampled at 1000 Hz.
Start by forming a time axis for our data, running from t=0 until
t=.25 in steps of 1 millisecond. Then form a signal, x, containing
sine waves at 50 Hz and 120 Hz.
t = 0:.001:.25;
x = sin(2*pi*50*t) + sin(2*pi*120*t);

Add some random noise with a standard deviation of 2 to


produce a noisy signal y. Take a look at this noisy signal y by
plotting it.
y = x + 2*randn(size(t));
plot(y(1:50))
title('Noisy time domain signal')

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)')

You might also like