%% Recover Bits from HT-Data Field
% Recover bits from the HT-Data field of an HT-mixed waveform transmitted through an additive white Gaussian noise (AWGN) channel.
% Configure an HT-mixed transmission and generate the corresponding HT-Data field.

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

% Transmit the signal through an AWGN channel with a signal-to-noise ratio (SNR) of 10 dB.

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

% Specify a channel estimate. Because the signal does not pass through a fading channel, a vector of ones is a perfect estimate. For a channel bandwidth of 20 MHz, the HT-SIG field contains 52 data subcarriers and 4 pilot subcarriers.

chEst = ones(56,1);

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

dataBits = wlanHTDataRecover(rxDataSig,chEst,noiseVarEst,cfgHT);
isequal(dataBits,bits)

% Copyright 2012 The MathWorks, Inc.