
You can apply sum to an array of type single and MATLAB returns an answer of type single. This section describes the support of sum for data types other than double. Finally, if A is a multidimensional array, Matlab works on the first non-singleton dimension of A what. If A is a matrix, Scilab sum (A) gives the sum of all elements of A but Matlab returns the sum of each column.

So, if A is a vector, then Scilab and Matlab work in the same way. This is called a magic square because the sums of the elements in each column are the same.Īs are the sums of the elements in each row, obtained by transposing: Msum (A) Scilab sum (A) returns the sum of all components of A. This is the default for single and double. This is the default for integer data types.ī = sum(., 'native') performs additions in the native data type of A and return an answer of the same data type. Sums along the dimension of A specified by scalar dim.ī = sum(., 'double') performs additions in double-precision and return an answer of type double, even if A has data type single or an integer data type. If A is a multidimensional array, sum(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors. If A is a matrix, sum(A) treats the columns of A as vectors, returning a row vector of the sums of each column.

If A is a vector, sum(A) returns the sum of the elements. Returns sums along different dimensions of an array. Sum (MATLAB Functions) MATLAB Function Reference
