%% BCC-Decode Two Encoded Streams
% Decode two encoded streams of soft bits by using a BCC of rate 1/2.
%
% Create the sequence of data bits.

dataBits = randi([0 1],100,1,'int8');

%
% Parse the data bits as defined in IEEE® 802.11™-2012 Section 20.3.11.5 and IEEE®  802.11ac™-2013 Section 22.3.10.5.2. numES is the number of encoded streams.

numES = 2;
parsedData = reshape(dataBits,numES,[]).';

%
% BCC-encode the parsed sequence.

encodedData = wlanBCCEncode(parsedData,'1/2');

%
% Convert the encoded bits to soft bits (i.e. LLR demodulation).

demodData = double(1-2*encodedData);

%
% BCC-decode the demodulated data.

decodedData = wlanBCCDecode(demodData,'1/2');

%
% Deparse the decoded data.

deparsedData = reshape(decodedData.',[],1);

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

isequal(dataBits,deparsedData)

% Copyright 2012 The MathWorks, Inc.