This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Reorder sequence of symbols


intrlvd = intrlv(data,elements)


intrlvd = intrlv(data,elements) rearranges the elements of data without repeating or omitting any elements. If data is a length-N vector or an N-row matrix, elements is a length-N vector that permutes the integers from 1 to N. The sequence in elements is the sequence in which elements from data or its columns appear in intrlvd. If data is a matrix with multiple rows and columns, the function processes the columns independently.


The command below rearranges the elements of a vector. Your output might differ because the permutation vector is random in this example.

p = randperm(10); % Permutation vector
a = intrlv(10:10:100,p)

The output is below.

a =

    10    90    60    30    50    80   100    20    70    40

The command below rearranges each of two columns of a matrix.

b = intrlv([.1 .2 .3 .4 .5; .2 .4 .6 .8 1]',[2 4 3 5 1])
b =

    0.2000    0.4000
    0.4000    0.8000
    0.3000    0.6000
    0.5000    1.0000
    0.1000    0.2000

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

Introduced before R2006a