image thumbnail


バージョン (2.43 KB) 作成者: Brett Shoelson
Compute the cumulative sum of matrices, specifying the treatment of NaNs.

ダウンロード 4.2K 件

更新 2016/9/1


nancumsum: Cumulative sum of a matrix, with user-specified treatment of NaNs.

Computes the cumulative sum of matrix A along dimension DIM, allowing the user to replace NaNs with zeros, to skip over them, or to reset on NaNs, maintaining NaNs as placeholders.

USAGE: B = nancumsum(A, DIM, NMODE)


A: Input matrix.

B: Output cumulative sum matrix, treating NaNs as determined by nmode.

DIM: B = nancumsum(A, DIM) returns the nan-cumulative sum of the elements
along the dimension of A specified by scalar DIM. For example,nancumsum(A,1) works down the columns, nancumsum(A,2) works across the rows. If DIM is not specified, it defaults to the first non-singleton dimension of A.

NMODE: specifies how NaNs should be treated. Acceptable values are:
1: REPLACE NaNs with zeros (default).
2: MAINTAIN NaNs as position holders in B. (Skip NaNs without reset.)
3: RESET sum on NaNs, replacing NaNs with zeros.
4: RESET sum on NaNs, maintaining NaNs as position holders.

See also: cumsum, nansum, nancumprod, nanmean, nanmedian, ...
(nancumprod is available from the FEX. Other nan* may require Toolboxes)


Brett Shoelson (2022). nancumsum (, MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007a
Windows macOS Linux
タグ タグの追加

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!