R = sum(M)
R = sum(M, d)
R = sum(M, 'all')
R = sum(M, ___, f)
R = sum(M, d, t)
R = sum(M, 'all', t, f)
| Parameter | Description |
|---|---|
| M | an array of double, single, integers, ... |
| d | dimension to operate along: positive integer scalar. |
| 'all' | sum all elements of M and return a scalar. |
| t | a string: 'default', 'double' or 'native'. |
| f | a string: 'includenan' or 'omitnan'. |
| Parameter | Description |
|---|---|
| R | Sum of array elements. |
R = sum(M) returns the sum along the first non-singleton dimension of M.
R = sum(M, d) sums along dimension d. R = sum(M, 'all') sums all elements of M and returns a scalar.
Optional text arguments control the output type ('default', 'double' or 'native') and NaN handling ('includenan' or 'omitnan').
M = [1 2; 3 4];
R = sum(M, 2)
M = [1 2; 3 4];
R = sum(M, 'all')
M = uint8([10:30:70;20:30:80;30:30:90]);
R = sum(M, 'native')
| Version | Description |
|---|---|
| 1.0.0 | initial version |