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.

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

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by