Created
January 7, 2020 11:12
-
-
Save pavhofman/1aad923d254e52ca425673ff06bbc158 to your computer and use it in GitHub Desktop.
Plotting undersampled signals
This file contains 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
pkg load signal; | |
FS = 48000; | |
MULTIPLE = 100; | |
CONT_FS = MULTIPLE * FS; | |
F = 20000; % 20kHz | |
tCont = transpose(0:1/CONT_FS:5 * 1/F); | |
fundCont = 0.5 * sin(2*pi *F * tCont); | |
h2Cont = 0.25 * sin(2*pi *2 *F * tCont); | |
framesCont = [tCont, fundCont + h2Cont]; | |
plot(framesCont(:, 1), framesCont(:, 2)); | |
hold on; | |
% downsampling to FS without filtering - simply keeping every MULTIPLEth sample | |
framesSampled = downsample(framesCont, MULTIPLE); | |
stem(framesSampled(:, 1), framesSampled(:, 2), '.o', 'linewidth', 2, 'markersize', 20); | |
F_SPUR = 8000; | |
spuriousCont = -0.125 * sin(2*pi *F_SPUR * tCont); | |
framesCont = [tCont, fundCont + 0.5 * h2Cont + spuriousCont]; | |
plot(framesCont(:, 1), framesCont(:, 2)); | |
% sampling at FS - keeping every MULTIPLEth sample | |
framesSampled = downsample(framesCont, MULTIPLE); | |
stem(framesSampled(:, 1), framesSampled(:, 2), '.x', 'linewidth', 2, 'markersize', 20); | |
hold off; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment