Selective summary of matrix array

1 回表示 (過去 30 日間)
Daniel Lee
Daniel Lee 2020 年 10 月 26 日
コメント済み: Daniel Lee 2020 年 10 月 26 日
Hi,
I'm trying to create 1 x 5 matrix called A with following information:
Given:
Let's say r=exprnd(5,1,5) yields following result:
r =
2.7059 16.3678 8.9145 0.7997 6.0534
Let's say first value in above r matrix (2.7059) is now called r1
Let's say second value in above r matrix (16.3678) is now called r2 and so on to r5 (=6.0534).
In the end, matrix A will be: [0+r1, r1+r2, r1+r2+r3, r1+r2+r3+r4, r1+r2+r3+r4+r5]
Question: Is there a function I can use to simplify matrix A definition? I would like to create a 1x1000 matrix A.
Thank you in advance.

採用された回答

KSSV
KSSV 2020 年 10 月 26 日
編集済み: KSSV 2020 年 10 月 26 日
Read about cumsum.
iwant = cumsum(A) ;
  1 件のコメント
Daniel Lee
Daniel Lee 2020 年 10 月 26 日
wow that was quick and it was exactly what I was looking for. Thank you!!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by