Elementwise multiplication of two 3D matrices
Mostrar comentarios más antiguos
I am trying to multiply two 3D matrices elementwise so the value in slot (1,1,1) in both matrices are multiplied together and the product taking that slot in the product matrix. I have tried to use pagemtimes to do this, but I recieved an error in response:
Error using pagemtimes
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first array matches the number of rows in the second array.
Both matrices are 100x130x100 so perhaps I am using the wrong function for what I wish to do. Would a for loop being the best direction? I am not much of a coder so apologizes if the solution seems obvious. The 3rd dimension to the matrices I think is throwing me off.
Respuesta aceptada
Más respuestas (2)
A = rand(3,6,9);
B = rand(3,6,9);
Product = A.*B
Walter Roberson
el 10 de Feb. de 2025
0 votos
pagemtimes is for page-by-page algebraic matrix multiplication. It takes two matrices of size [A B C] and [B D C] and produces a result that is size [A D C]. It is not element-by-element matrix multiplication. Element-by-element matrix multiplication is just the .* operator
Categorías
Más información sobre Creating and Concatenating Matrices 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!
