Member of the basic class.
c = sum(a)
c = sum(a, b)
Computes the sum of vectors and matrices.
| Name | Description | ||||
| a | Specifies a vector or matrix. | ||||
| b | Specifies the dimension along which to compute the sum. b accepts the following values.
|
| Name | Description |
| c | Returns the sum of all elements in a if a is a vector. If a is a matrix, c returns the column-wise sums of the elements in a. c is a scalar or row vector. |
A = [1:1:15]
C = sum(A)
A = [1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12]
sum(A, 1)
sum(A, 2)