Understanding Aliasing, Sampling Rate and the Use of Power Spectral Densities
Aliasing is the misinterpretation of high frequencies (above half of the sampling frequency) as lower frequencies. This is a problem that must be avoided when digitizing continuous signals.
Examples:
This m-file psdchk1.m below demonstrates how to determine the frequency of an incoming signal. The user will specify up to three functions. These functions are summed and their resulting function is then plotted and its Power Spectral Density (PSD) is calculated and plotted. Click here for an example using this m-file.
Exercise:
It is important to try different functions, sampling rates and total time of gathered data to see its effects. Of course in real applications, the input function is rarely known and you must rely purely on the output for analysis. Try different inputs and see if you can determine the function solely by viewing the two graphs.
Can you tell the frequencies of the three functions by only reviewing the PSD plot?
What about the Amplitude of each function? Can this be estimated from the PSD plot?
% This m-file psdchk1.m was created by Professor Ron Adrezin
% of The Cooper Union, School of Engineering
% on 5/04/97. It was last modified on 5/04/97.
%
% The purpose of this m-file is to demonstrate how to
% determine the frequency of an incoming signal.
% The user will specify up to three functions.
% These functions are summed and their
% resulting function is then plotted and its Power Spectral
% Density (PSD) is calculated and plotted.
%
% Can you tell the frequencies of the three functions
% by only reviewing the PSD plot? What about the Amplitude
% of each function? Can this be estimated from the PSD plot?
%
%
% FunctA: the first function
% A1: amplitude of the first function in meters
% f1: frequency of the first function in Hz
% FunctB: the second function
% A2: amplitude of the second function in meters
% f2: frequency of the second function in Hz
% FunctC: the third function
% A3: amplitude of the third function in meters
% f3: frequency of the third function in Hz
% FunctTotal: the sum of the three functions
% fs: the sampling frequency in Hz
% t: time in seconds
% t0: start time in seconds
% tf: final time in seconds
clear all;
t0=0;
tf=30;
fs=20;
A1=2;
A2=300;
A3=60;
f1=.1;
f2=8;
f3=3;
t=t0:1/fs:tf;
FunctA=A1*sin(2*pi*f1*t);
FunctB=A2*sin(2*pi*f2*t);
FunctC=A3*sin(2*pi*f3*t);
FunctTotal =FunctA+FunctB+FunctC;
figure(1)
subplot(3,1,1);
plot(t,FunctTotal);
xlabel('time [s]');
ylabel('displacement [m]');
title('Plot of FunctTotal');
subplot(3,1,3);
p=spectrum(FunctTotal,512); %This requires at least 1024 points
% It also must be 2 to a power.
specplot
(p,fs);
Support for the development of this module was provided by the National Science Foundation and The Cooper Union for the Advancement of Science and Art.
Please send questions or comments to Professor Ron Adrezin or Professor Daniel Raichel.