%% BPSK and QBPSK Demapping  for VHT-SIG-A Field
% BPSK and QBPSK demapping for different OFDM symbols for the VHT-SIG-A field by using a soft demodulation. The demapping is defined in IEEE®  802.11ac™-2013 Section 22.3.8.3.3
%
% Create the sequence of data bits. Specify the two OFDM symbols in columns.

 bits = randi([0 1],48,2,'int8');

%
% Perform constellation mapping on the data bits. Specify the size of the constellation rotation as the number in columns of the input sequence. The first column is mapped with a BPSK modulation. The second column is modulated with a QBPSK modulation.

numBPSCS = 1;
phase = [0 pi/2];
mappedData = wlanConstellationMap(bits,numBPSCS,phase);

%
% Perform the constellation demapping with an estimated variance noise equal to zero (no added noise). To derotate the constellation, specify the same phase as in the mapping function. The output is a vector of soft bits ready to be the input of a convolutional decoder.

noiseVar = 0;
demappedData = wlanConstellationDemap(mappedData,noiseVar,numBPSCS,phase);

%
% Verify that the demapped data matches the original data. Because no noise is present, you can recover the original data without errors by assigning the negative values to a logical 1 and the positive values to a logical 0. In other words, you can convert the soft bits into hard bits.

demappedBits = int8((demappedData<=0));
isequal(bits,demappedBits)

% Copyright 2012 The MathWorks, Inc.