How I compute multiple sum in matlab for 4D matrix?
조회 수: 1 (최근 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에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!