%% Recover Bits from VHT-Data Field Using Zero-Forcing Equalization
% Recover bits from the VHT-Data field signal of a VHT transmission recovered from a SISO AWGN channel by using a zero-forcing equalization algorithm.
% Configure a VHT transmission and generate the VHT-Data field for a random payload of bits.

cfgVHT = wlanVHTConfig('APEPLength',512);
psduLength = 8*cfgVHT.PSDULength;
bits = randi([0 1],psduLength,1); 
txDataSig = wlanVHTData(bits,cfgVHT);

% Pass the transmission through an AWGN channel.

snr = 10;
rxDataSig = awgn(txDataSig,snr);

% Recover the payload bits using a perfect channel estimate of all ones and zero-forcing equalization.

chEst = ones(242,1);
noiseVarEst = 10^(-snr/10);
[dataBits,crcBits,eqSym,cpe] = wlanVHTDataRecover(rxDataSig,chEst,noiseVarEst,cfgVHT,'EqualizationMethod','ZF');

% Verify that the recovered signal contains no bit errors.

number = biterr(bits,dataBits)

% Display the VHT-Data field CRC checksum bits.

disp(crcBits')

% Calculate and display the maximum common phase error.

max(abs(cpe))

% Copyright 2012 The MathWorks, Inc.