View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
modified cumsum for partial accumulated sums

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.54 KB File ID: #40893 Version: 1.0

modified cumsum for partial accumulated sums



Determine the accumulated sum of series of non-zero values of vectors, resetting at zero entries

| Watch this File

File Information

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
 ind indicates the locations where the acummulated sum is stored
 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]'

MATLAB release MATLAB 5.3 (R11)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us