Arrange the matrix by replace a part to another part

1 回表示 (過去 30 日間)
mohammed hussein
mohammed hussein 2021 年 7 月 19 日
コメント済み: mohammed hussein 2021 年 7 月 19 日
Hi
I have 4 matrices as example, I would like to arrange these matrices to be one big matrix after keep only (the beginning of rows and columns) as this example
If I have
A1=ones(12);
A2=ones(9)*2;
A3=ones(6)*3;
A4=ones(4)*4;
I would like to find the final matrix after keep only the first 3 (the beginning of rows and columns in each matrix ) , so the final matriix should be like
ATOT=
[1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4];
please i would like to specify the number of (the beginning of rows and columns) that should keep because i have diffrent size of matrices
thank you very much
  2 件のコメント
Aakash Deep Chhonkar
Aakash Deep Chhonkar 2021 年 7 月 19 日
編集済み: Aakash Deep Chhonkar 2021 年 7 月 19 日
Also, focus on which part of the matrix you want to update rather than which part you want to preserve, this will clear the picture more.
mohammed hussein
mohammed hussein 2021 年 7 月 19 日
thank you

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

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 7 月 19 日
Assuming your matrices are conveniently sized...
A1=ones(12);
A2=ones(9)*2;
A3=ones(6)*3;
A4=ones(3)*4;
A = A1;
A(4:end,4:end) = A2;
A(7:end,7:end) = A3;
A(10:end,10:end) = A4
Output:
A =
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4
  1 件のコメント
mohammed hussein
mohammed hussein 2021 年 7 月 19 日
thank you for your answer

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

その他の回答 (0 件)

カテゴリ

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