Arrange the matrix by replace a part to another part

1 visualización (últimos 30 días)
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 comentarios
Aakash Deep Chhonkar
Aakash Deep Chhonkar el 19 de Jul. de 2021
Editada: Aakash Deep Chhonkar el 19 de Jul. de 2021
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.

Iniciar sesión para comentar.

Respuesta aceptada

Scott MacKenzie
Scott MacKenzie el 19 de Jul. de 2021
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

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by