How to multiply 4D array.
조회 수: 3 (최근 30일)
이전 댓글 표시
i want to multiply
L(:,:,k,:).*M(:,:,k,:);
i want to multiply without loop.
댓글 수: 0
채택된 답변
Christine Tobler
2015년 12월 17일
편집: Christine Tobler
2015년 12월 17일
You could try downloading the tensor toolbox by Kolda and Bader, where this is provided as a command ttt(L, M, 3, 3). Alternatively, you can use the following code:
permL = permute(L, [3 1 2 4]);
permM = permute(M, [3 1 2 4]);
szL = size(L);
szM = size(M);
result = permL(:, :)'*permM(:, :);
result = reshape(result, [szL([1 2 4]), szM([1 2 4])]);
This returns a 6-dimensional array result, such that
result(i1, i2, i3, j1, j2, j3)
is the same as
a = 0; for k=1:size(L, 3), a = a + L(i1, i2, k, i3)*M(j1, j2, k, j3); end; a
Is this what you wanted to compute?
댓글 수: 2
Christine Tobler
2015년 12월 18일
I'm not sure what you want L and M to be, can you explain in more detail?
추가 답변 (1개)
Walter Roberson
2015년 12월 17일
L.*M
Somehow I suspect that your question missed some information...
댓글 수: 0
참고 항목
카테고리
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!