Scilab 6.0.2

- Aide de Scilab
- Aide à la conversion Matlab vers Scilab
- Matlab-Scilab equivalents
- S
- save (Matlab function)
- schur (Matlab function)
- setstr (Matlab function)
- sign (Matlab function)
- sin (Matlab function)
- sinh (Matlab function)
- size (Matlab function)
- sort (Matlab function)
- sparse (Matlab function)
- sqrt (Matlab function)
- strcmp (Matlab function)
- strcmpi (Matlab function)
- strfind (Matlab function)
- strrep (Matlab function)
- struct (Matlab function)
- sum (Matlab function)
- surf (Matlab function)
- svd (Matlab function)
- switch (Matlab function)

Aide de Scilab >> Aide à la conversion Matlab vers Scilab > Matlab-Scilab equivalents > S > sum (Matlab function)

# sum (Matlab function)

Sum of array elements

### Particular cases

- M=sum(A)
Scilab

**sum(A)**returns the sum of all components of**A**. So, if**A**is a vector, then Scilab and Matlab work in the same way. If**A**is a matrix, Scilab**sum(A)**gives the sum of all elements of**A**but Matlab returns the sum of each column. Finally, if**A**is a multidimensional array, Matlab works on the first non-singleton dimension of**A**what Scilab does not. So, to be sure to find a Scilab equivalent for Matlab call to**sum**it is better to precise dimension on which to work.- M=sum(A,dim)
In Scilab

**dim=1**is equivalent to**dim="r"**and**dim=2**is equivalent**dim="c"**. In Matlab, dim can be greater then the number of dimension of**A**(in this case,**M=A**), in Scilab you will get an error message.

## Comments

Add a comment:Please login to comment this page.