how to sum matrices in a for loop
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    reza hamzeh
 el 21 de Oct. de 2019
  
    
    
    
    
    Respondida: David Hill
      
      
 el 22 de Oct. de 2019
            hi every body. suppose the bellow code. this code give me 16 matrices. how can i sum all of this matrices by using these for-loops?
for i=1:4
    for j=1:4
        a=[0 1:1 0];
        b=[1 0:0 1];
        x=i*a+j*b;
    end
end
0 comentarios
Respuesta aceptada
  David Hill
      
      
 el 22 de Oct. de 2019
        I assume you just want to add the calculated x-matrix with itself during each loop iteration.
x=zeros(2);
for i=1:4
    for j=1:4
        a=[0 1:1 0];
        b=[1 0:0 1];
        x=x+i*a+j*b;
    end
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

