Product of three 1d vectors and a 3d array
1 view (last 30 days)
Show older comments
Marco Vona
on 17 Jul 2020
Answered: Abdolkarim Mohammadi
on 17 Jul 2020
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?
0 Comments
Accepted Answer
Abdolkarim Mohammadi
on 17 Jul 2020
aPermuted = a(:);
bPermuted = permute (b(:),[2,1,3]);
cPermuted = permute (c(:),[3,2,1]);
Z = T .* aPermuted .* bPermuted .* cPermuted;
Result = sum (Z,'all');
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!