%% Build VHT PPDU
% Build VHT PPDUs by using the waveform generator function or by building each field individually.
%% Waveform Generator
% Create a VHT configuration object.

vht = wlanVHTConfig;

%
% Generate the VHT PPDU. The length of the input data sequence in bits must be 8 times the length of the PSDU, which is expressed in bytes. Turn off windowing.

x = randi([0 1],vht.PSDULength*8,1);
y = wlanWaveformGenerator(x,vht,'WindowTransitionTime',0);

%
% Plot the magnitude of the waveform.

t = ((1:length(y))'-1)/80e6;
plot(t,abs(y))
xlabel('Time (s)')
ylabel('Magnitude (V)')

%
%% Individual PPDU Fields
% Create L-STF, L-LTF, L-SIG, VHT-SIG-A, VHT-STF, VHT-LTF, and VHT-SIG-B preamble fields.

lstf = wlanLSTF(vht);
lltf = wlanLLTF(vht);
lsig = wlanLSIG(vht);
vhtSigA = wlanVHTSIGA(vht);
vhtstf = wlanVHTSTF(vht);
vhtltf = wlanVHTLTF(vht);
vhtSigB = wlanVHTSIGB(vht);

%
% Generate the VHT-Data field using input data field x, which was used as an input to the waveform generator.

vhtData = wlanVHTData(x,vht);

%
% Concatenate the individual fields to create a single PPDU.

z = [lstf; lltf; lsig; vhtSigA; vhtstf; vhtltf; vhtSigB; vhtData];

%
% Verify that the PPDUs created by the two methods are identical.

isequal(y,z)

% Copyright 2012 The MathWorks, Inc.