필터 지우기
필터 지우기

How I compute multiple sum in matlab for 4D matrix?

조회 수: 3 (최근 30일)
Mehdi
Mehdi 2018년 9월 11일
댓글: Mehdi 2018년 9월 11일
How I compute multiple sum in matlab for 4D matrices as below? U and V are 4D matrices.
  댓글 수: 12
Mehdi
Mehdi 2018년 9월 11일
편집: Mehdi 2018년 9월 11일
As I said I have many similar expressions like that and it seems your method is not applicable for more expressions. I am searching a similar command like add in Maple.
Matt J
Matt J 2018년 9월 11일
편집: Matt J 2018년 9월 11일
If they are "similar", my method - which is to use the sum command - is applicable. Have you read the documentation on sum()? It is the best analogue of add that you will find in Matlab.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
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
Matt J
Matt J 2018년 9월 11일
편집: Matt J 2018년 9월 11일
You should edit your original post with this new equation and information about q_r and q_s. The new expression is rather unclear. You have the symbol q being used for two different things, both as a symbolic variable and as an index of summation.
Mehdi
Mehdi 2018년 9월 11일
I asked the question in new page as below: https://uk.mathworks.com/matlabcentral/answers/418526-what-is-the-best-way-to-calculate-multiple-summations-expression-in-matlab

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by