This octave/MATLAB script shows the effect of not sampling fast enough.

From Class Wiki
Jump to: navigation, search

Two sinewaves fit the same sample points. (There are actually an infinite number that fit. Can you figure out the next higher frequency one?)

% This program demonstrates how a couple of sine waves can be
% sampled and have the same sample values.
clf;
f=1;
tmax =5;
T = .8;
fs = 1/T; %1.25 Hz sample rate
t=0:.01:tmax;
x = cos(2*pi*f*t);
hold on;
tk=0:T:tmax;
xk = cos(2*pi*f*tk);
y = cos(2*pi*(f-fs)*t);
plot(t,x,'b',tk,xk,'ro',t,y,'g');
legend('First Signal','Data Samples','Second Signal');
title('Aliasing in the Time Domain');
xlabel('Time (seconds)');
ylabel('Signals');
figure(1);
hold off;

Sinewaves aliasing.png