alias demo
Plot one sampled waveform
% Try this: % Set freq = 40 Hz (Nyquist frequency) and plot sine and then cosine N = 81; freq = 4; t = linspace(0,1,81); dt = t(2) - t(1); fs = 1/dt; fn = fs/2.0; fprintf('sample frequency: %g Hz\n',fs); str = sprintf('frequency %8.2f f_N\n',freq/fn); x = 0.9*sin(2*pi*freq*t); plot(t,x); axis([0 1 -1 1]); title(str); xlabel('time (sec)'); ylabel('signal level');
sample frequency: 80 Hz
N = 81; t = linspace(0,1,81); dt = t(2) - t(1); fs = 1/dt; fn = fs/2; close all; aviobj = avifile('alias1.avi','Compression','Cinepak'); fig = figure; for freq = [linspace(2,160,241) 4]; x = 0.9*sin(2*pi*freq*t); plot(t,x); axis([0 1 -1 1]); xlabel('time (sec)'); ylabel('signal level'); str = sprintf('frequency %8.2f f_N\n',freq/fn); title(str); F = getframe(fig); aviobj = addframe(aviobj,F); end aviobj = close(aviobj);