Skip to content

Instantly share code, notes, and snippets.

@robodhruv
Created February 24, 2018 19:30
Show Gist options
  • Save robodhruv/bb794542297f750fd88a8a2e1e6e3be5 to your computer and use it in GitHub Desktop.
Save robodhruv/bb794542297f750fd88a8a2e1e6e3be5 to your computer and use it in GitHub Desktop.
Visualise frequency confusing/aliasing due to sampling of a pure sinusoid as a video.
clear all; close all;
n = [0:0.1:50];
w = pi/2;
Ts = 0.2;
ks = [-200:200];
y = zeros(size(n))
frame_count = 1;
for k = ks
y = y + cos(w*n*Ts + 2*pi*k*n);
if ((mod(k, 10) == 3) || (k < 10))
plot(n, y/max(y))
F(frame_count) = getframe(gcf);
frame_count = frame_count + 1;
end
end
vid = VideoWriter('result.mp4');
open(vid);
writeVideo(vid, F);
close(vid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment