Documentation

This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

sum (DataMatrix)

Return sum of elements in DataMatrix object

Syntax

```S = sum(DMObj) S = sum(DMObj, Dim) S = sum(DMObj, Dim, IgnoreNaN) ```

Input Arguments

 `DMObj` DataMatrix object, such as created by `DataMatrix` (object constructor). `Dim` Scalar specifying the dimension of `DMObj` to calculate the sums. Choices are:`1` — Default. Returns sum of elements in each column.`2` — Returns sum of elements in each row. `IgnoreNaN` Specifies if NaNs should be ignored. Choices are `true` (default) or `false`.

Output Arguments

 `S` Either of the following:Row vector containing the sums of the elements in each column in `DMObj` (when `Dim` = `1`)Column vector containing the sums of the elements in each row in `DMObj` (when `Dim` = `2`)

Description

`S = sum(DMObj)` returns the sum of the elements in the columns of a DataMatrix object, treating NaNs as missing values. `S` is a row vector containing the sums of the elements in each column in `DMObj`. If the values in `DMObj` are `single`s, then `S` is a `single`; otherwise, `S` is a `double`.

`S = sum(DMObj, Dim)` returns the sum of the elements in the columns or rows of a DataMatrix object, as specified by `Dim`. If `Dim` = `1`, returns `S`, a row vector containing the sums of the elements in each column in `DMObj`. If `Dim` = `2`, returns `S`, a column vector containing the sums of the elements in each row in `DMObj`. Default `Dim` = `1`.

`S = sum(DMObj, Dim, IgnoreNaN)` specifies if NaNs should be ignored. `IgnoreNaN` can be `true` (default) or `false`.