Multiply a "stack" of matrices with a "stack" of vectors
Mostrar comentarios más antiguos
I have a matrix 2 x 2 x n and a vector 2 x n. So basically, I have n layers of 2 x 2 matrices and n layers of vectors with 2 entries. I d like to do a matrix-vector multiplication on each layer.
I could easily do this using a for loop, but is there a way which directly supports such an operation?
Respuesta aceptada
Más respuestas (1)
James Tursa
el 4 de Mzo. de 2014
Editada: James Tursa
el 7 de Mzo. de 2014
Some options in the FEX:
C-mex code:
C-mex code:
m-code:
You may need to reshape the 2 x n to a 2 x 1 x n for some of these methods to work.
Also this explicit m-code:
result = sum(bsxfun(@times,M,reshape(v,1,2,n)),2);
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!