runlength.m

[l,s] = runlength(x,R) parses the vector x into "runs" of constant value.
3.1K Downloads
Updated 4 Jun 1998

No License

[l,s] = runlength(x,R) parses the vector x into 'runs' of constant value.

x - row or column vector
R - maximum run length

l - length of run
s - value of run

Eg. x = [0 0 0 pi pi -1 -1 7 7 7 7 nan inf inf -inf];
R = 3;

l = [ 3 2 2 3 1 1 2 1 ];
s = [ 0 3.14 -1 7 7 nan inf -inf ];

Output vectors have the same orientation as the input vector.

Cite As

Owen Kelly (2024). runlength.m (https://www.mathworks.com/matlabcentral/fileexchange/241-runlength-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0