arrangment matrix in special way

1 回表示 (過去 30 日間)
mohammed hussein
mohammed hussein 2021 年 12 月 10 日
コメント済み: mohammed hussein 2021 年 12 月 10 日
Dear All
I have question about arrangement matrix. I have three small matrices used to arrange big matrix in special way like this example
If I have two small matrices and third one is transpose of second one.
A = (green )
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
B = (blue)
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
C= transpose(B) (gray )
17 21 25 29
18 22 26 30
19 23 27 31
20 24 28 32
I want to arrange matrix (D) in size (20*20) like the picture inserted. please if you can help me to arrange the matrix for different size of input matrices (small matrices) and output matrix (big matrix) will be perfect for me.

採用された回答

David Hill
David Hill 2021 年 12 月 10 日
Z=zeros(4);
d=[A;B;Z;Z;C];
D=d;
for k=2:5
d=circshift(d,4,1);
D=[D,d];
end
  1 件のコメント
mohammed hussein
mohammed hussein 2021 年 12 月 10 日
thank you very much for you answer , it works perfectly

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

その他の回答 (1 件)

Voss
Voss 2021 年 12 月 10 日
D = zeros(20,20);
for offset = (0:4)*4
idx = offset+(1:4);
D(idx,idx) = A;
D(mod(idx+4-1,20)+1,idx) = B;
D(mod(idx-4-1,20)+1,idx) = C;
end
The mod operations are to "wrap" B and C back around to where they go in D when they would otherwise go off the top or bottom of D.
  1 件のコメント
mohammed hussein
mohammed hussein 2021 年 12 月 10 日
thank you very much for you answer , it works perfectly

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by