MATLAB Answers

Sum of matrix elements

4 views (last 30 days)
I have that matrix
p=[4 9 3 3 6 8 8 12 6]
and i want to reach that one
k=[4 13 16 19 25 33 41 53 59]
I made with for loop but is seems like
k=[13 16 19 25 33 41 53 59 ]
how can i fix it?

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 29 May 2019
Edited: Stephen Cobeldick on 29 May 2019
>> k = cumsum(p)
k =
4 13 16 19 25 33 41 53 59

  0 Comments

Sign in to comment.

More Answers (1)

ES
ES on 29 May 2019
cumsum(p)

  0 Comments

Sign in to comment.

Sign in to answer this question.