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 Center および File ExchangeOperating 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