Arrange the matrix by replace a part to another part

1 次查看(过去 30 天)
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

采纳的回答

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