%% Find Nearest Reference Symbols for DMG-Format Configuration
% Find the closest reference symbols to a received set of noisy symbols in a DMG-format configuration.
% Create a DMG-format configuration object, specifying the MCS.

cfg = wlanDMGConfig('MCS',10);

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

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

% Generate noise to be added to the signal, specifying the SNR.

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

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

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

% Find the closest reference symbols for the specified configuration.

refSym = wlanClosestReferenceSymbol(sym,cfg);

% Copyright 2018 The MathWorks, Inc.