Product of three 1d vectors and a 3d array
1 次查看(过去 30 天)
显示 更早的评论
Say I am given three n-dimesional vectors
and an
array T. Is there a way to compute the quantity
without using a for loop?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333348/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333351/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333354/image.png)
0 个评论
采纳的回答
Abdolkarim Mohammadi
2020-7-17
aPermuted = a(:);
bPermuted = permute (b(:),[2,1,3]);
cPermuted = permute (c(:),[3,2,1]);
Z = T .* aPermuted .* bPermuted .* cPermuted;
Result = sum (Z,'all');
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!