File Exchange

image thumbnail

block diagonal representation

version (2.07 KB) by David Holdaway
Converts a matrix into a cell array of different sized matrices that make up the blocks.

1 Download

Updated 11 Apr 2012

View License

Essentially if one has a matrix M that they wish to store more efficiently in memory/use for function bldiagmult.m (same author), then use
cellform = blkdiagconv( M );
this is such that using the inbuilt Matlab function one has
M == blkdiag(cellform{:})
it is essentially the inverse function to blkdiag.

Cite As

David Holdaway (2021). block diagonal representation (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)


Yes indeed.

David H

I think tommsch

blkdiag( [0 0 0;0 1 0;0 0 0] );
yields {[0],[1 0;0 0]}.

Is the behaviour I actually intended, that way it is the inverse to blkdiag, unless I have missed something very obvious here.


For the following matrix, the result is wrong or at least very unexpected:
blkdiag( [0 0 0;0 1 0;0 0 0] );
yields {[0],[1 0;0 0]}.
One should replace the lines
if k ==1
rngud(k,:) =[1,1];
rngud(k,:) = rngud(k-1,:);
rngud(k,:) = [k k];

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: mat2blk

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!