フィルターのクリア

Sub-Matrices in a bigger matrix

3 ビュー (過去 30 日間)
Rengin
Rengin 2019 年 7 月 19 日
編集済み: Jan 2019 年 7 月 19 日
Dear Users,
Imagine that I have 4 square matrices such as A11, B11, C11 and D22.
I want to insert them as diagonal elements of a bigger matrix (please see the pic on the attchments).
However, I don't know the size of the bigger matrix. I will find it out when I insert all sub-matrices. Is there any easy way to do it?
Thanks in advance!

採用された回答

madhan ravi
madhan ravi 2019 年 7 月 19 日
blkdiag(A11, B11, C11, D22)
  2 件のコメント
Rengin
Rengin 2019 年 7 月 19 日
Thank you for the answer! Do you also know how to implement other sub-matrices in this big matrix (please see e.g. A12, A13, B21...etc. in the figure on the attcahments) ?
madhan ravi
madhan ravi 2019 年 7 月 19 日
m = size(A11,1);
Wanted = blkdiag(A11, B11, C22, D22);
Wanted(1:m,m+1:end) = [A12,A13,A14];
Wanted(m+1:m*2,1:m) = B21

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2019 年 7 月 19 日
For matrices with the same size. Let [m,n] - size of each matrix, q - number of matrices in the vertical of a large matrix:
M = cat(3,A11,B21,..,A12,B11,..,A13,..,C11,..D22);% A11, B21 and etc - your small matrices
out = reshape(permute(reshape(M,m,n,q,[]),[1,3,2,4]),q*m,[]);

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by