How I compute multiple sum in matlab for 4D matrix?
4 次查看(过去 30 天)
显示 更早的评论
How I compute multiple sum in matlab for 4D matrices as below? U and V are 4D matrices.

12 个评论
回答(1 个)
Matt J
2018-9-11
编辑:Matt J
2018-9-11
Notice that the only indices shared between U and V are j and q. Therefore, you can minimize multiplication operations as follows,
partialU=sum(sum(U,4),1); %sum over i and r
partialV=sum(sum(V,4),1); %sum over k and s
A=sum(partialU(:).*partialV(:)); %sum over j and q
6 个评论
另请参阅
类别
在 Help Center 和 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!