Contenuto principale

randdeintrlv

R2026b

Restore ordering of symbols using random permutation

Description

deintrlvd = randdeintrlv(data,stream) restores the original ordering of the elements in data by inverting a random permutation. The output of this function is repeatable for a given same random stream with the same state, but different random streams and different states produce different permutations. For more information, see RandStream.

To use this function as an inverse of the randintrlv function, create two identical random streams, one for the interleaver and one for the deinterleaver. In that case, applying randintrlv followed by randdeintrlv leaves data unchanged.

example

Examples

collapse all

Create two identical random streams, one for the interleaver and one for the deinterleaver.

s1 = RandStream('mt19937ar',Seed=12345);
s2 = RandStream('mt19937ar',Seed=12345);
data = randi([0 255],1,10)
data = 1×10

   208   231    32   233   161    24    71   140   245   247

intlvData = randintrlv(data,s1)
intlvData = 1×10

    32   233   231   161    24   140   247   245   208    71

deintlvData = randdeintrlv(intlvData,s2)
deintlvData = 1×10

   208   231    32   233   161    24    71   140   245   247

Use the same random stream for both interleaver and deinterleaver. To get the same state, you must reset the random stream before each interleaving or deinterleaving operation.

  stream = RandStream('mt19937ar',Seed=12345);
  data = randi([0 255],1,10)
data = 1×10

   208   231    32   233   161    24    71   140   245   247

  intlvData = randintrlv(data,stream)
intlvData = 1×10

    32   233   231   161    24   140   247   245   208    71

  reset(stream)
  deintlvData = randdeintrlv(intlvData,stream)
deintlvData = 1×10

   208   231    32   233   161    24    71   140   245   247

  reset(stream)
  intlvData = randintrlv(data,stream)
intlvData = 1×10

    32   233   231   161    24   140   247   245   208    71

  reset(stream)
  deintlvData = randdeintrlv(intlvData,stream)
deintlvData = 1×10

   208   231    32   233   161    24    71   140   245   247

This example shows how an interleaver improves the error rate in a communications system whose channel produces a burst of errors. A random interleaver rearranges the bits of numerous codewords before two adjacent codewords are each corrupted by three errors.

Three errors exceed the error-correction capability of the Hamming code. However, when the Hamming code is combined with an interleaver, this system is able to recover the original message despite the 6-bit burst of errors. The improvement in performance occurs because the interleaving effectively spreads the errors among different codewords so that the number of errors per codeword is within the error-correction capability of the code.

st1 = 27221; st2 = 4831;    % States for random number generator
n = 7; k = 4;               % Parameters for Hamming code
msg = randi([0 1],k*500,1); % Data to encode
code = encode(msg,n,k,'hamming/binary'); % Encoded data

Create a burst error that will corrupt two adjacent codewords.

errors = zeros(size(code));
errors(n-2:n+3) = [1 1 1 1 1 1];

Display the bit error rate with interleaving and deinterleaving applied.

inter = randintrlv(code,st2);                       % Interleave
inter_err = bitxor(inter,errors);                   % Include burst error
deinter = randdeintrlv(inter_err,st2);              % Deinterleave
decoded = decode(deinter,n,k,'hamming/binary');     % Decode

Number of errors and error rate, with interleaving:

[number_with,rate_with] = biterr(msg,decoded)       % Error statistics
number_with = 
0
rate_with = 
0

Display the bit error rate with no interleaving and deinterleaving applied.

code_err = bitxor(code,errors);                     % Include burst error
decoded = decode(code_err,n,k,'hamming/binary');    % Decode

Number of errors and error rate, with no interleaving:

[number_without,rate_without] = biterr(msg,decoded) % Error statistics
number_without = 
4
rate_without = 
0.0020

Input Arguments

collapse all

Interleaved signal, specified as a vector or matrix. If data is a matrix with multiple rows and columns, the function processes the columns independently.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32
Complex Number Support: Yes

Random stream that determines the specific permutation, specified as a RandStream object.

Output Arguments

collapse all

Deinterleaved data, returned with the same dimensions and data type as the input data.

Version History

Introduced before R2006a

See Also

Functions

Objects