block diagonal matrix in the opposite diagonal

조회 수: 2 (최근 30일)
Romio
Romio 2022년 9월 18일
댓글: Romio 2022년 9월 18일
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

채택된 답변

Paul
Paul 2022년 9월 18일
Here's one option
a = rand(2);
b = rand(2,3);
A = blkdiag(a,b)
A = 4×5
0.0976 0.7033 0 0 0 0.6779 0.8610 0 0 0 0 0 0.4852 0.7807 0.6937 0 0 0.5431 0.4091 0.2433
D = oppblkdiag(a,b)
D = 4×5
0 0 0 0.0976 0.7033 0 0 0 0.6779 0.8610 0.4852 0.7807 0.6937 0 0 0.5431 0.4091 0.2433 0 0
function D = oppblkdiag(varargin)
c = cellfun(@(x) fliplr(x),varargin,'UniformOutput',false);
D = fliplr(blkdiag(c{:}));
end
  댓글 수: 2
John D'Errico
John D'Errico 2022년 9월 18일
Exactly.
Romio
Romio 2022년 9월 18일
Thanks. I think it should be implemeted as built in function in matlab

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by