Sunday, December 9, 2018

discrete signals - Shifting Sequences Using MATLAB


I'm reading the book Vinay Ingle, John Proakis - Digital Signal Processing Using MATLAB® (3rd Edition) and I came across a function to shift sequences. Mathematically,



$$ y(n) = \{x(n-k) \} $$


if $m = n-k$, then $$ y(m+k) = \{ x(m) \} $$


function [y,n] = sigshift(x,m,k)
n = m + k;
y = x;
end

This function shifts nothing. I've tried to find errata list of the book, but I couldn't find it. Is this function correct?



Answer



This function just changes the x-axis for plotting signals. It's indeed pretty trivial but the idea is to use it like this:



n = 0:4;
x = [1 2 3 2 1]; % some signal
[y,m] = sigshift(x,n,3); % shift to the right by 3 samples
subplot(2,1,1), stem(n,x)
subplot(2,1,2), stem(m,y)

enter image description here


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...