Find the cumulative sum of the columns of

Trang Mắm

New member
Find the cumulative sum of the columns of A.
Code:
  A =1     4     7
     2     5     8
     3     6     9
B = cumsum(A)
A.
B = 1 4 7
3 8 15
6 15 24
B.
B = 1 4 7
4 9 15
4 15 24
C.
B = 1 4 7
3 9 15
6 15 29
D.
B = 1 4 7
3 9 15
6 15 24
 
Answer: d
Explanation: B = cumsum(A) returns the cumulative sum of A starting at the beginning of the first array dimension in A whose size does not equal 1. If A is a matrix, then cumsum(A) returns a matrix containing the cumulative sums for each column of A. B(5) is the sum of A(4) and A(5), while B(9) is the sum of A(7), A(8), and A(9).
 

Tìm kiếm

Back
Top