sum
Returns vector or matrix element sums.
Syntax
R = sum(A)
R = sum(A,dim)
Inputs
- A
- The argument from which to sum elements.
- dim
- The dimension on which to multiply.
Outputs
- R
- The sums of elements.
Examples
Vector:
R = sum([1,2,3])
R = 6
Matrix with a specified dimension:
R = sum([1,2,3; 4 5 6],2)
R = [Matrix] 2 x 1
6
15
Matrix with all dimensions:
R = sum([1,2,3; 4 5 6],'all')
R = 21