Created
July 26, 2017 03:23
-
-
Save stephenHartzell/be6676a4c231d864387980aa099c1b63 to your computer and use it in GitHub Desktop.
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
% The 2D signal | |
y = [ 1 -1 4 8 zeros(1,12)]; | |
N = length(y); | |
% Plot unshifted signal | |
figure | |
subplot(2,1,1), stem(y), title('Unshifted Signal') | |
% Frequency domain samples | |
f = 0:N-1; | |
% The shift | |
k = 6; | |
% The exponential | |
shft = exp((-2*pi*i/N)*k*f); | |
% The shifting operation | |
Y = fft(y); | |
Yshft = Y.*shft; | |
yshft = real(ifft(Yshft)); | |
% The real part of the ifft must be selected because sometimes due to | |
% computational errors on the part of the computer there will be a very | |
% small imaginary residual | |
subplot(2,1,2), stem(yshft), title('Shifted Signal') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment