%% Find Closest Reference Symbols for 64-QAM
% Find the closest reference symbols to a received set of noisy symbols for 64-QAM.
% Create a high-efficiency single-user-format (HE-SU-format) configuration object, specifying a modulation and coding scheme (MCS) with 64-QAM.

cfg = wlanHESUConfig('MCS',6);

% Obtain the PSDU length.

psduLength = getPSDULength(cfg); 

% Generate a waveform for a payload of randomly generated bits and the specified configuration.

bits = randi([0 1],8*psduLength,1,'int8');
waveform = wlanWaveformGenerator(bits,cfg);

% Generate noise to be added to the signal, specifying the signal-to-noise ratio (SNR).

SNR = 10;
rxWaveform = awgn(waveform,SNR);

% Get the field indices and extract the HE-Data field.

ind =  wlanFieldIndices(cfg);
sym = rxWaveform(ind.HEData(1):ind.HEData(2));

% Find the closest reference symbols for the specified modulation scheme.

mod = '64QAM';
refSym = wlanClosestReferenceSymbol(sym,mod);

% Copyright 2018 The MathWorks, Inc.