this question has answer here:
let's have matrix in matlab like
a = [1 2 3; 4 5 6; 7 8 9]
and obtain matrix of form
b = [1 0 0; 0 4 0; 0 0 7; 2 0 0; 0 5 0; 0 0 8; 3 0 0; 0 6 0; 0 0 9]
i.e. matrix concatenation of 3 diagonal matrices, each having columns of matrix @ diagonals. know how using loop on columns of , concatenating results looking shorter way this. please share ideas.
b(repmat(eye(3),3,1)==1) = a; reshape(b, [], 3)
Comments
Post a Comment