Tools for Processing Consecutive Repetitions in Vectors

Version 3.0.9 (12.1 KB) by Matt J
A set of functions for labeling and manipulating groups of consecutively repeating elements in a vector.
119 Downloads
Updated Wed, 25 Jan 2023 13:05:27 +0000

View License

This FEX submission provides some functions that are similar to MATLAB's usual findgroups() and splitapply() commands, except that they are specifically well-suited to scenarios where the groups are subsets of consecutively repeating elements in a vector.
EXAMPLE: To find the run lengths of consecutive non-zero elements in,
>> X=[0 0 4 7 6 1 3 0 0 0 1 11 3 8 0 0 47 14];
one can simply do,
>> runlengths = groupFcn(@length, X, groupTrue(X>0) )
runlengths =
5 4 2
For a more detailed description and examples, see the Examples tab.

Cite As

Matt J (2024). Tools for Processing Consecutive Repetitions in Vectors (https://www.mathworks.com/matlabcentral/fileexchange/78008-tools-for-processing-consecutive-repetitions-in-vectors), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
3.0.9

Small bug fix in groupConsec.m
Only affected case when the input sequence started with 0.

3.0.8

Updates Examples.mlx to include an illustration of groupLims().

3.0.7

More documentation fixes

3.0.6

Some documentation corrections.

3.0.5

Upgraded groupReductFcn and groupReductHybrid with the capability of taking matrix-valued input.

3.0.4

Added some new functions: groupLims, groupReductFcn, and groupReductHybrid.

3.0.3

Fixed small bug in groupFcn. Error message was triggered in the case of multi-input functions.

3.0.2

Edit

3.0.1

Edit

2.0.6

Renamed group1s to groupTrue

2.0.5

Edits

2.0.4

Edits

2.0.3

Edited text and examples.

2.0.2

Small text edits

2.0.1

Small text edits

2.0.0

Added groupConsec and groupFcn

1.0.0