Find sequences of repeated (adjacent/consecutive) numeric values. NaNs and Infs are supported.
2,2K téléchargements
Mise à jour 11 nov. 2013

Afficher la licence

Find sequences of repeated (adjacent/consecutive) numeric values. Finds sequences of NaNs and Infs too.

(1) FINDSEQ(A) Find sequences of repeated numeric values in A along the first non-singleton dimension. A shuld be a numeric nD matrix.
(2) FINDSEQ(A,DIM) Look for sequences along the dimension specified by the positive integer scalar DIM.

OUT = findseq(...)
OUT is a "m by 4" numeric matrix where m is the number of sequences found.
Each sequence has 4 columns where:
- 1st col.: the value being repeated
- 2nd col.: the position of the first value of the sequence
- 3rd col.: the position of the last value of the sequence
- 4th col.: the length of the sequence

[VALUES, INPOS, FIPOS, LEN] = findseq(...)
Get OUT as separate outputs.

For details see help
For examples see the attached image.

Comments/suggestions/error reports are welcome.
p10v5 - Update strongly recommended due to major bug in output sorting in v4.

Citation pour cette source

Oleg Komarov (2024). FINDSEQ (, MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2012a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Inspiré par : rude: a pedestrian run-length decoder-encoder, GETCHUNKS

A inspiré : Clipping Indicator

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version

Fixed major bug in the sorting of Final position that relied on regularity conditions not always verified

Per Herbert Gsenger's suggestion fixed bug in matching initial and final positions; minor change to distribution of OUT if multiple outputs; added 3D example

Per Zachary Danziger's suggestion reorganized check structure to avoid bug when concatenating results

Cast double on logical instead of single when treating NaNs and Infs

Per Xiaohu's suggestion fixed bug in output dimensions when A is row vector

Reorganized code and fixed bug when concatenating results