Created
February 24, 2018 19:30
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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