Code covered by the BSD License  

Highlights from
MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

image thumbnail

MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

by

 

29 Oct 2012 (Updated )

These files are the MatLab solutions of exercises contained in the above DSP lab textbook.

shiftright(x,n)
function y = shiftright(x,n)
% This function shifts to the right (left) the contents of a row vector
% and inserts zeros at the left (right)- most places. 
% If n>0 (n<0), it moves the contents to the right (left).
% x is assumed a row vector.
x = x(:).';
N = length(x);

if abs(n)<=N
    y = zeros(1,N);
    if n>0
        y = [ zeros(1,n)  x([1:N-n]) ];
    elseif n==0
        y = x;
    elseif n<0
        y = [ x([-n+1:N])  zeros(1,-n) ];
    end
else 
     disp('Error: Shift length should be less than or equal to given vector''s length')
end
    

Contact us