runlength.m

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

You are now following this Submission

[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 (2026). runlength.m (https://www.mathworks.com/matlabcentral/fileexchange/241-runlength-m), MATLAB Central File Exchange. Retrieved .

Tags

Add Tags

Add the first tag.

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0