Summation with multiple FOR loops?

1 回表示 (過去 30 日間)
Max Wever
Max Wever 2022 年 5 月 18 日
回答済み: Michal 2022 年 5 月 18 日
Hi, I am still learning my way around matlab.
I need to code this function:
I am stuck in how to do those multiple summations.
Thanks in advance,
Max

回答 (1 件)

Michal
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.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by