Elementwise multiplication of two 3D matrices
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (2)
A = rand(3,6,9);
B = rand(3,6,9);
Product = A.*B
Walter Roberson
am 10 Feb. 2025
0 Stimmen
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
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
