function B = Shift(A,s); % B = Shift(A,s); % % Circularly shift the rows of matrix A by s entries. % Positive s shifts right, while negative s shifts left. % If s exceeds the matrix dimensions, modulo addressing is % applied. % % St.Weiss, University of Strathclyde, 16.7.1997 [m,n] = size(A); s = mod(s,n); B = [A(:,n-s+1:n) A(:,1:n-s)];