%% Recover HT-Data Field Using Zero-Forcing Algorithm
% Recover the HT-Data field and calculate the common phase error of an HT-mixed signal recovered from an AWGN channel by using zero-forcing equalization at the receiver.
% Configure an HT-mixed transmission with a channel bandwidth of 40 MHz and a PSDU length of 1024 bytes, then generate the corresponding HT-Data field.

psduLength = 1024;
cfgHT = wlanHTConfig('ChannelBandwidth','CBW40','PSDULength',psduLength);
bits = randi([0 1],8*psduLength,1);
txDataSig = wlanHTData(bits,cfgHT);

% Pass the signal through an AWGN channel with an SNR of 7 dB.

snr = 7;
noiseVarEst = 10^(-snr/10);
rxDataSig = awgn(txDataSig,7);

% Specify a channel estimate.

chEst = ones(114,1);

% Recover the bits from the received HT-Data field and confirm that the recovered bits match the transmitted bits.

[dataBits,eqSym,cpe] = wlanHTDataRecover(rxDataSig,chEst,noiseVarEst,cfgHT,'EqualizationMethod','ZF');
isequal(bits,dataBits)

% Calculate and display the maximum common phase error.

max(abs(cpe))

% Copyright 2012 The MathWorks, Inc.