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

ht = wlanHTConfig;

%
% Generate the HT 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 windowing off.

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

%
% Plot the magnitude of the waveform.

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

%
%% Individual PPDU Fields
% Create L-STF, L-LTF, L-SIG, HT-SIG, HT-STF, and HT-LTF preamble fields.

lstf = wlanLSTF(ht);
lltf = wlanLLTF(ht);
lsig = wlanLSIG(ht);
htsig = wlanHTSIG(ht);
htstf = wlanHTSTF(ht);
htltf = wlanHTLTF(ht);

%
% Generate the HT-Data field using input data field x, which is the same input signal that was used with the waveform generator.

htData = wlanHTData(x,ht);

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

z = [lstf; lltf; lsig; htsig; htstf; htltf; htData];

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

isequal(y,z)

% Copyright 2012 The MathWorks, Inc.