|
"Raymond " <atlantaswagsurfers3@yahoo.com> wrote in message <i6cb3e$dmo$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message <i6cagl$7ns$1@fred.mathworks.com>...
> > Have you seen CIRCSHIFT?
>
> Not allowed to use that unfortunately. Only using mod, :, vec(vec())...etc.
Like this?
%Vector to shift and shift
A = [1 2 3 4 5];
shift = 3;
%Matrix of combos (twice the size for the purpose of negative shifts)
T = repmat(triu(toeplitz(A))+tril(toeplitz([0 A(end:-1:2)])),2,1);
%Row Selection
T(max(rem(shift,5)+1,numel(A)+abs(mod(shift,5))+1),:)
:)
|