This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Compute period of sequence


p = seqperiod(x)
[p,num] = seqperiod(x)


p = seqperiod(x) returns the integer p that corresponds to the period of the sequence in a vector x. The period p is computed as the minimum length of a subsequence x(1:p) of x that repeats itself continuously every p samples in x. The length of x does not have to be a multiple of p, so that an incomplete repetition is permitted at the end of x. If the sequence x is not periodic, then p = length(x).

  • If x is a matrix, then seqperiod checks for periodicity along each column of x. The resulting output p is a row vector with the same number of columns as x.

  • If x is a multidimensional array, then seqperiod checks for periodicity along the first nonsingleton dimension of x. In this case:

    • p is a multidimensional array of integers with a leading singleton dimension.

    • The lengths of the remaining dimensions of p correspond to those of the dimensions of x after the first nonsingleton one.

[p,num] = seqperiod(x) also returns the number num of repetitions of x(1:p) in x. num might not be an integer.


collapse all

Generate a multichannel signal and determine the period of each column.

x = [4 0 1 6;
     2 0 2 7;
     4 0 1 5;
     2 0 5 6];

p = seqperiod(x)
p =

     2     1     4     3

The first column of x has period 2. The second column of x has period 1. The third column of x is not periodic, so p(3) is just the number of rows of x. The fourth column of x has period 3, although the second repetition of the periodic sequence is incomplete.

Introduced before R2006a

Was this topic helpful?