Product of three 1d vectors and a 3d array

1 view (last 30 days)
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?

Accepted Answer

Abdolkarim Mohammadi
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');

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!