Borrar filtros
Borrar filtros

Addition for loop in matrices

2 visualizaciones (últimos 30 días)
Surendra Maharjan
Surendra Maharjan el 26 de Mzo. de 2021
Comentada: Rik el 26 de Mzo. de 2021
Hello Matlab Community,
I would like to add A and B matrices using for loop such that I can add B into A, element-wise 2x2, and moving column-wise till 5th element and move to second row, and adding B and moving column till 5th element again and move to third row and fourth row consequently.
A = zeros(5,5);
B = [1, 2; 3, 4];
Thank you very much.
Suren
  2 comentarios
Stephen23
Stephen23 el 26 de Mzo. de 2021
@Surendra Maharjan: please show the expected output for your example data.
Rik
Rik el 26 de Mzo. de 2021
25 is not a multiple of 4. Should the replication of B just stop there?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by