Elementwise multiplication of two 3D matrices
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (2)
A = rand(3,6,9);
B = rand(3,6,9);
Product = A.*B
Walter Roberson
le 10 Fév 2025
0 votes
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
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
