%% Estimate VHT Packet Symbol Timing
% Return the symbol timing and decision metric of an 802.11ac™ packet without channel impairments.
% Create a VHT format configuration object. Specify two transmit antennas and two space-time streams.

cfgVHT = wlanVHTConfig;
cfgVHT.NumTransmitAntennas = 2;
cfgVHT.NumSpaceTimeStreams = 2;

%
% Generate a VHT format transmit waveform. Add a 50-sample delay at the start of the waveform.

txWaveform = wlanWaveformGenerator([1;0;0;1],cfgVHT);
txWaveform = [zeros(50,cfgVHT.NumTransmitAntennas); txWaveform];

%
% Extract the non-HT preamble fields. Obtain the timing offset estimate and decision metric.

ind = wlanFieldIndices(cfgVHT);
nonhtfields = txWaveform(ind.LSTF(1):ind.LSIG(2),:);
[startOffset,M] = wlanSymbolTimingEstimate(nonhtfields, ...
    cfgVHT.ChannelBandwidth);

%
% Plot the returned decision metric for the non-HT preamble of the VHT format transmission waveform.

figure
plot(M)
xlabel('Symbol Timing Index')
ylabel('Decision Metric (M)')

% Copyright 2012 The MathWorks, Inc.