This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Scramble and descramble binary input sequence


y = wlanScramble(bits,scramInit)



y = wlanScramble(bits,scramInit) scrambles or descrambles the binary input bits for the specified initial scramble state, using a 127-length frame-synchronous scrambler. The frame-synchronous scrambler uses the generator polynomial defined in IEEE® 802.11™-2012, Section and IEEE 802.11ad™-2012, Section 21.3.9. The same scrambler is used to scramble bits at the transmitter and descramble bits at the receiver.


collapse all

Create the scrambler initialization and the input sequence of random bits.

scramInit = 93;
bits = randi([0,1],1000,1);

Scramble and descramble the bits by using the scrambler initialization.

scrambledData = wlanScramble(bits,scramInit);
descrambledData = wlanScramble(scrambledData,scramInit);

Verify that the descrambled data matches the original data.

ans = logical

Input Arguments

collapse all

Input sequence to be scrambled, specified as a binary column vector or matrix.

Data Types: double | int8

Initial state of the scrambler, specified as an integer from 1 to 127, or a corresponding 7-by-1 column vector of binary bits.

The scrambler initialization used on the transmission data follows the process described in IEEE Std 802.11-2012, Section and IEEE Std 802.11ad-2012, Section 21.3.9. The header and data fields that follow the scrambler initialization field (including data padding bits) are scrambled by XORing each bit with a length-127 periodic sequence generated by the polynomial S(x) = x7+x4+1. The octets of the PSDU (Physical Layer Service Data Unit) are placed into a bit stream, and within each octet, bit 0 (LSB) is first and bit 7 (MSB) is last. The generation of the sequence and the XOR operation are shown in this figure:

Conversion from integer to bits uses left-MSB orientation. For the initialization of the scrambler with decimal 1, the bits are mapped to the elements shown.

Bit Value0000001

To generate the bit stream equivalent to a decimal, use de2bi. For example, for decimal 1:

ans =

     0     0     0     0     0     0     1

Same scramInit is applied across all the columns of bits when the input is a matrix.

Example: [0 0 0 0 0 0 1]'

Data Types: double

Output Arguments

collapse all

Scrambled or descrambled output, returned as a binary column vector or matrix with the same size and type as bits.

Extended Capabilities

Introduced in R2017b

Was this topic helpful?