Documentation Center

  • Trial Software
  • Product Updates

intrlv

Reorder sequence of symbols

Syntax

intrlvd = intrlv(data,elements)

Description

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.

Examples

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

More About

See Also

Was this topic helpful?