special sum of an array

2 ビュー (過去 30 日間)
Rica
Rica 2015 年 6 月 30 日
回答済み: Sean de Wolski 2015 年 6 月 30 日
hi all, is there any function to do this simply:
Array=[a1 a2 .......an]
i want to calculate this:
ArraySum=[a1 a1+a2 a1+a2+a3 .......a1+a2+a3+...an]
Thank you!

採用された回答

Sean de Wolski
Sean de Wolski 2015 年 6 月 30 日
That's a cumulative sum, cumsum is the function you want:
a = [1 2 3]
cumsum(a)
ans =
1 3 6

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by