modified cumsum for partial accumulated sums

版本 1.0.0.0 (1.5 KB) 作者: Stephan Koehler
Determine the accumulated sum of series of non-zero values of vectors, resetting at zero entries
297.0 次下载
更新时间 2013/3/21

查看许可证

This is a modified version of cumsum, where the accumulated sum is determined along the first non-singleton direction of an input tensor "arr". The accumulated sums are stored in the output tensor "val" at locations of the zeros of arr.

[val, ind] = cumsum_restart0( arr, dim )
if dim is not defined, use first non-singleton dimension
val is the cumulative sum, where the accumulation is reset for zero
entries
ind indicates the locations where the acummulated sum is stored

example:
arr = [3 1 1 0 1 2]';
[val, ind] = cum_sum_restart0( arr );
val = [0 0 5 0 0 3]'
ind = [0 0 1 0 0 1]'

3/20/13
koehler.s.a@gmail.com

引用格式

Stephan Koehler (2024). modified cumsum for partial accumulated sums (https://www.mathworks.com/matlabcentral/fileexchange/40893-modified-cumsum-for-partial-accumulated-sums), MATLAB Central File Exchange. 检索时间: .

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

Community Treasure Hunt

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

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