%% Generate VHT Waveform with Specified Transmission Time
% Create a wlanVHTConfig object, 'cfgPHY', and specify the transmission time, 'txTime', in microseconds.

cfgPHY = wlanVHTConfig;
txTime = 200;

% Calculate the APEP length in octets.

apepLength = wlanAPEPLength(cfgPHY,'TxTime',txTime)

% Set the number of bytes carried in the user payload for the configuration object, 'cfgPHY', to this APEP length.

cfgPHY.APEPLength = apepLength;

% Create a wlanMACFrameConfig object, 'cfgMAC'. Use this object to generate a VHT-format QoS data frame.

cfgMAC = wlanMACFrameConfig('FrameType','QoS Data', ...
    'FrameFormat','VHT');

% Calculate the MAC service data unit (MSDU) lengths required to generate a MAC frame of size 'APEPLength'.

msduLengths = wlanMSDULengths(apepLength,cfgMAC,cfgPHY);

% Create random MSDUs using 'msduLengths'.

msduList = cell(1, numel(msduLengths));
for i = 1:numel(msduLengths)
    msduList{i} = randi([0 255],1,msduLengths(i));
end

% Generate MAC frame bits using the MSDUs, 'msduList'.

macFrameBits = wlanMACFrame(msduList,cfgMAC,cfgPHY,'OutputFormat','bits');

% Generate a VHT waveform using 'cfgPHY' and the generated MAC frame bits, 'macFrameBits'.

waveform = wlanWaveformGenerator(macFrameBits,cfgPHY);

% Copyright 2019 The MathWorks, Inc.