%% Segment-Deparse Coded Bits in Two OFDM Symbols
% Segment-deparse the coded bits for a VHT configuration (with a channel bandwidth of 160 MHz and three spatial streams) into two OFDM symbols.
%
% Define the input parameters. Set the channel bandwidth to 160 MHz, the number of coded bits per OFDM symbol to 2808, the number of spatial streams to 3, the number of encoded streams to 1, the number of coded bits per subcarrier per spatial stream to 2,  and the number of OFDM symbols to 2. Calculate the number of coded bits per OFDM symbol per spatial stream by dividing the number of coded bits per OFDM symbol by the number of spatial streams.

chanBW = 'CBW160';
numCBPS = 2808;
numSS = 3;
numES = 1;
numBPSCS = 2;
numSym = 2;
numCBPSS = numCBPS/numSS;

%
% Create the input sequence of bits.

bits = randi([0 1],numCBPSS*numSym,numSS);

%
% Perform segment parsing on the bits.

parsedBits = wlanSegmentParseBits(bits,chanBW,numES,numCBPS,numBPSCS);
size(parsedBits)

%
% Perform segment deparsing on the parsed bits.

 deparsedBits = wlanSegmentDeparseBits(parsedBits,chanBW,numES,numCBPS,numBPSCS);
 size(deparsedBits)

%
% Verify that the deparsed data matches the original data.

isequal(bits,deparsedBits)

% Copyright 2012 The MathWorks, Inc.