%% Demap 4-D Array
% Perform BPSK demapping on a four-dimensional array by using hard demodulation.
% Create the sequence of data bits as an array of four dimensions, with 416 coded bits per subcarrier per spatial stream per interleaver block, four OFDM symbols, two spatial streams, and two segments.

numCBPSSI = 416; 
numSym = 4;
numSS = 2;
numSeg = 2; 
bits = randi([0 1],numCBPSSI,numSym,numSS,numSeg);
size(bits)

% Perform BPSK constellation mapping on the data bits with a rotation of  \frac{\pi }{2} radians.

numBPSCS = 1;
phase = pi/2;
sym = wlanConstellationMap(bits,numBPSCS,phase);
size(sym)

% Perform hard QBPSK constellation demapping. To derotate the constellation, specify the same phase as in the mapping function.

noiseVarEst = 0;
demapType = 'hard';
y = wlanConstellationDemap(sym,noiseVarEst,numBPSCS,demapType);

% Verify that the demapped data matches the original data.

isequal(bits,y)

% Copyright 2012 The MathWorks, Inc.