3D Matrix Multiply
显示 更早的评论
- Assume a vector V which is (P X 1) array.
- Assume matrices A,B which is (M X N X P) array.
I want to multiply A(i, j, :) .* V for each 0 < i <= M , and 0 < j <= N.
Currently I'm using loops to make it happen:
for ii = 1 : M
for jj = 1 : N
B(ii, jj, :) = V.* squeeze(A(ii, jj, :));
end
end
Is there any way to do so which doesn't include any use of loops?
1 个评论
madhan ravi
2018-12-18
How about this?
a= rand(3,2,3); %M X N XP
V=rand(2,1); %P X 1
A=permute(a,[3 2 1])
A(:,:,1) * V % V multiplied with first page?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!