function vc = blkM2vc(M, blkS) %blkM2vc Reshaping of a block-matrix into a matrix of vectors % % The matrix M consists of blocks of size blkS = [r c] % Each r by c block of the matrix M is converted into % a rc by 1 vector and placed as a column of the matrix vc [rr cc] = size(M) ; r = blkS(1) ; c = blkS(2) ; if (rem(rr, r) ~= 0) | (rem(cc, c) ~= 0) error('blocks do not fit into matrix') end nr = rr/r ; nc = cc/c ; rc = r*c ; vc = zeros(rc, nr*nc); for ii = 0:nr-1 vc(:, (1:nc)+ii*nc) = reshape(M((1:r)+ii*r, :), rc, nc) ; end