block diagonal matrix in the opposite diagonal
7 views (last 30 days)
Show older comments
Is there any function/way to construct a matrix with block matrcies in the opposite diagonal. I know of blkdiag( ) but it gives a matrix with blocks in the main diagonal
0 Comments
Accepted Answer
Paul
on 18 Sep 2022
Here's one option
a = rand(2);
b = rand(2,3);
A = blkdiag(a,b)
D = oppblkdiag(a,b)
function D = oppblkdiag(varargin)
c = cellfun(@(x) fliplr(x),varargin,'UniformOutput',false);
D = fliplr(blkdiag(c{:}));
end
More Answers (0)
See Also
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!