%% Recover HT-SIG in 2x2 MIMO Channel
% Recover HT-SIG in a 2x2 MIMO channel with AWGN. Confirm that the CRC check passes.
% Configure a 2x2 MIMO TGn channel.

chanBW = 'CBW20';
cfg = wlanHTConfig( ...
    'ChannelBandwidth',chanBW, ...
    'NumTransmitAntennas',2, ...
    'NumSpaceTimeStreams',2);

%
% Generate L-LTF and HT-SIG waveforms.

txLLTF  = wlanLLTF(cfg);
txHTSIG = wlanHTSIG(cfg);

%
% Set the sample rate to correspond to the channel bandwidth. Create a TGn 2x2 MIMO channel without large scale fading effects.

fsamp = 20e6;
tgnChan = wlanTGnChannel('SampleRate',fsamp, ...
    'LargeScaleFadingEffect','None', ...
    'NumTransmitAntennas',2, ...
    'NumReceiveAntennas',2);

%
% Pass the L-LTF and HT-SIG waveforms through a TGn channel with white noise.

rxLLTF = awgn(tgnChan(txLLTF),20);
rxHTSIG = awgn(tgnChan(txHTSIG),20);

%
% Demodulate the L-LTF signal. Generate a channel estimate by using the demodulated L-LTF.

demodLLTF = wlanLLTFDemodulate(rxLLTF,chanBW,1);
chanEst = wlanLLTFChannelEstimate(demodLLTF,chanBW);

%
% Recover the information bits, the CRC failure status, and the equalized symbols from the received HT-SIG field.

[recHTSIGBits,failCRC,eqSym] = wlanHTSIGRecover(rxHTSIG, ...
    chanEst,0.01,chanBW);

%
% Verify that HT-SIG passed a CRC check by examining the status of failCRC.

failCRC

% Because failCRC is 0, HT-SIG passed the CRC check.
%
% Visualize the scatter plot of the equalized symbols, eqSym.

scatterplot(eqSym(:))

% Copyright 2012 The MathWorks, Inc.