incremental sum in array

6 ビュー (過去 30 日間)
ANAND ASP
ANAND ASP 2021 年 2 月 9 日
回答済み: Jan 2021 年 2 月 9 日
A=[45 48 63 84 32]
B=[272 227 179 116 32]
A is matrix which has some randm numbers, Matrix B is answer
Logic is, we have to start sum from last element that is 32
last second element in answer (B) is 32+84 = 116
last third element in answer (B) is 32+84+63 = 179
last fourth element in answer (B) is 32+84+63+48 = 227
last fifth element in answer (B) is 32+84+63+48+45 = 272 and so on...
  1 件のコメント
Stephen23
Stephen23 2021 年 2 月 9 日
What have you tried so far?

サインインしてコメントする。

採用された回答

Jan
Jan 2021 年 2 月 9 日
A = [45 48 63 84 32]
cumsum(A, 'reverse')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by