Create a matrix by shifting a matrix column by column to
Show older comments
I have matrix 'a'. How can I create matrix 'b'?

Answers (2)
Walter Roberson
on 21 Nov 2017
b = zeros(9, 4);
for K = 1 : 3
b((K-1)*3+1:K*3, K:K+1) = a;
end
Andrei Bobrov
on 21 Nov 2017
Edited: Andrei Bobrov
on 21 Nov 2017
b = kron(convmtx(a(1,:),3),ones(size(a,1),1));
or
s = size(a);
r = 2*s(2);
v = (1:s(1))';
b = kron(a0(rem((1:r) + flip(v),r)*s(1) + v),ones(s(1),1));
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!