www.gusucode.com > wlan 源码程序 matlab案例代码 > wlan/RecoverHTDataFrom2x2MIMOChannelExample.m

    %% Recover HT Data from 2x2 MIMO Channel
% Transmit an HT-LTF and an HT data field through a noisy 2x2 MIMO channel.
% Demodulate the received HT-LTF to estimate the channel coefficients.
% Recover the HT data and determine the number of bit errors.
%%
% Set the channel bandwidth and corresponding sample rate.
bw = 'CBW40';
fs = 40e6;
%%
% Create HT-LTF and HT data fields having two transmit antennas and two
% space-time streams.
cfg = wlanHTConfig('ChannelBandwidth',bw, ...
    'NumTransmitAntennas',2,'NumSpaceTimeStreams',2);
txPSDU = randi([0 1],8*cfg.PSDULength,1);
txLTF = wlanHTLTF(cfg);
txDataSig = wlanHTData(txPSDU,cfg);

%%
% Create a 2x2 MIMO TGn channel with path loss and shadowing enabled.
tgnChan = wlanTGnChannel('SampleRate',fs, ...
    'NumTransmitAntennas',2,'NumReceiveAntennas',2, ...
    'LargeScaleFadingEffect','None');
%%
% Create AWGN channel noise, setting SNR = 15 dB.
chNoise = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (SNR)',...
    'SNR',15);
%%
% Pass the signals through the TGn channel and noise models.
rxLTF = chNoise(tgnChan(txLTF));
rxDataSig = chNoise(tgnChan(txDataSig));
%%
% Create an AWGN channel for a 40 MHz channel with a 9 dB noise figure. The
% noise variance, |nVar|, is equal to _kTBF_, where _k_ is Boltzmann's
% constant, _T_ is the ambient temperature of 290 K, _B_ is the bandwidth
% (sample rate), and _F_ is the receiver noise figure.
nVar = 10^((-228.6 + 10*log10(290) + 10*log10(fs) + 9)/10);
awgnChan = comm.AWGNChannel('NoiseMethod','Variance','Variance',nVar);
%%
% Pass the signals through the channel.
rxLTF = awgnChan(rxLTF);
rxDataSig = awgnChan(rxDataSig);
%%
% Demodulate the HT-LTF. Use the demodulated signal to estimate the channel
% coefficients.
dLTF = wlanHTLTFDemodulate(rxLTF,cfg);
chEst = wlanHTLTFChannelEstimate(dLTF,cfg);
%%
% Recover the data and determine the number of bit errors.
rxPSDU = wlanHTDataRecover(rxDataSig,chEst,nVar,cfg);
numErr = biterr(txPSDU,rxPSDU)