Elementwise multiplication of two 3D matrices
이전 댓글 표시
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.
채택된 답변
추가 답변 (2개)
A = rand(3,6,9);
B = rand(3,6,9);
Product = A.*B
Walter Roberson
2025년 2월 10일
0 개 추천
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
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
