getchunks¶
- getchunks(a, opt)
GETCHUNKS Get the number of repetitions that occur in consecutive chunks. C = GETCHUNKS(A) returns an array of n elements, where n is the number of consecutive chunks (2 or more repetitions) in A, and each element is the number of repetitions in each chunk. A can be LOGICAL, any numeric vector, or CELL array of strings. It can also be a character array (see below, for its special treatment).
Example
A = [1 2 2 3 4 4 4 5 6 7 8 8 8 8 9]; getchunks(A)
- ans =
2 3 4
[C, I] = GETCHUNKS(A) also returns the indices of the beginnings of the chunks.
GETCHUNKS(A, OPT) when OPT is ‘-full’, includes single-element chunks as well. Default OPT is ‘-reps’ (meaning REPEATING chunks).
If A is a character array, then it finds words (consecutive non-spaces), returning number of chararcters in each word and the indeces to the beginnings of the words. In this case, OPT has no effect.
Example
A = ‘This is a generic (simple) sentence’; [C, I] = getchunks(A)
- C =
4 2 1 7 8 8
- I =
1 6 9 11 19 28
See also HIST, HISTC.