nancumsum

版本 1.5.0.1 (2.4 KB) 作者: Brett Shoelson
Compute the cumulative sum of matrices, specifying the treatment of NaNs.
4.3K 次下载
更新时间 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)

ARGUMENTS:

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 (2024). nancumsum (https://www.mathworks.com/matlabcentral/fileexchange/14895-nancumsum), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.5.0.1

Updated license

1.5.0.0

Fixes an issue with the vectorization of mode 3.

1.3.0.0

This submission fixes a bug pointed out by a couple of attentive users. Also, note that I have added new options for the treatment of NaNs, and eliminated one for special treatment of vectors. (Not necessary!)

1.2.0.0

Updated M file and license text file copyright to The MathWorks, Inc.

1.1.0.0

added copyright

1.0.0.0

Fixing a bug (failed for scalar inputs).