compute the sum of each item of a vector with every item of another vector
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Christoph Meier
 el 1 de Mzo. de 2016
  
    
    
    
    
    Respondida: Sean de Wolski
      
      
 el 1 de Mzo. de 2016
            Dear matlab community,
i came across a simple problem, which should be easily solved by one of the more experienced members.
I have two vectors, say
1
2
3
and
4
5
6
Now, I want to compute sums with each of the vector item from the first vector and every vector item of the second vector, that the answer is as follows:
1+4
1+5
1+6
2+4
2+5
2+6
3+4
3+5
3+6
Thank you very much!
0 comentarios
Respuesta aceptada
  Sean de Wolski
      
      
 el 1 de Mzo. de 2016
        bsxfun(@plus,1:3,(4:6)')
You can reshape it after if you want it as a 9x1
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical 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!

