Summation with multiple FOR loops?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I am still learning my way around matlab.
I need to code this function:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002015/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002015/image.png)
I am stuck in how to do those multiple summations.
Thanks in advance,
Max
댓글 수: 0
답변 (1개)
Michal
2022년 5월 18일
Admitting I didn't go into the tensor train definition... but basically, in Matlab when you have a N-dimensional array, you can just tell the sum() function which dimension to sum along. See help for sum(). So if you define your multidimensional arrays of the tensor train, summing them is that easy.
For example: A is 10x20x100, you ask B = sum(A, 3) and you'll get B which is a 10x20 array, each element of it a sum of the 100 elements under it in the 3rd dimension.
댓글 수: 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!