FINDSEQ
by Oleg Komarov
02 Jul 2010
(Updated 22 Mar 2012)
Find sequences of repeated (adjacent/consecutive) numeric values. NaNs and Infs are supported.
|
Watch this File
|
| File Information |
| Description |
Find sequences of repeated (adjacent/consecutive) numeric values. Finds sequences of NaNs and Infs too.
SYNTAXES:
(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.
p10v4
|
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
rude: a pedestrian run-length decoder-encoder, GETCHUNKS
|
| MATLAB release |
MATLAB 7.14 (R2012a)
|
| Other requirements |
Tested on R14SP3 (7.1) and on R2012b. In-between compatibility is assumed. |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 07 Jul 2010 |
Reorganized code and fixed bug when concatenating results |
| 12 Jul 2010 |
Per Xiaohu's suggestion fixed bug in output dimensions when A is row vector |
| 27 Aug 2010 |
Cast double on logical instead of single when treating NaNs and Infs |
| 30 Aug 2010 |
Per Zachary Danziger's suggestion reorganized check structure to avoid bug when concatenating results |
| 22 Mar 2012 |
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 |
|
Contact us at files@mathworks.com