%% Demonstrate SIGB Compression in HE MU Waveforms
%% HE MU-MIMO Configuration With SIGB Compression
% Generate a full bandwidth HE MU-MIMO configuration at 20 MHz bandwidth with SIGB compression. All three users are on a single content channel, which includes only the user field bits.

cfgHE = wlanHEMUConfig(194);
cfgHE.NumTransmitAntennas = 3;

% Create PSDU data for all users.

psdu = cell(1,numel(cfgHE.User));
psduLength = getPSDULength(cfgHE);
for j = 1:numel(cfgHE.User)
    psdu = randi([0 1],psduLength(j)*8,1,'int8');
end

% Generate and plot the waveform.

y = wlanWaveformGenerator(psdu,cfgHE);
plot(abs(y))

% Generate a full bandwidth HE MU-MIMO waveform at 80 MHz bandwidth with SIGB compression. HE-SIG-B content channel 1 has four users. HE-SIG-B content channel 2 has three users.

cfgHE = wlanHEMUConfig(214);
cfgHE.NumTransmitAntennas = 7;

% Create PSDU data for all users.

psdu = cell(1,numel(cfgHE.User));
psduLength = getPSDULength(cfgHE);
for j = 1:numel(cfgHE.User)
    psdu = randi([0 1],psduLength(j)*8,1,'int8');
end

% Generate and plot the waveform.

y = wlanWaveformGenerator(psdu,cfgHE);
plot(abs(y));

%% HE MU-MIMO Configuration Without SIGB Compression
% Generate a full bandwidth HE MU-MIMO configuration at 20 MHz bandwidth without SIGB compression. All three users are on a single content channel, which includes both common and user field bits.

cfgHE = wlanHEMUConfig(194);
cfgHE.SIGBCompression = false;
cfgHE.NumTransmitAntennas = 3;

% Create PSDU data for all users.

psdu = cell(1,numel(cfgHE.User));
psduLength = getPSDULength(cfgHE);
for j = 1:numel(cfgHE.User)
    psdu = randi([0 1],psduLength(j)*8,1,'int8');
end

% Generate and plot the waveform.

y = wlanWaveformGenerator(psdu,cfgHE);
plot(abs(y))

% Generate an 80 MHz HE MU waveform for six users without SIGB compression. HE-SIG-B content channel 1 has four users. HE-SIG-B content channel 2 has two users.

cfgHE = wlanHEMUConfig([202 114 192 193]);
cfgHE.NumTransmitAntennas = 6;
for i = 1:numel(cfgHE.RU)
    cfgHE.RU{i}.SpatialMapping = 'Fourier';
end

% Create PSDU data for all users.

psdu = cell(1,numel(cfgHE.User));
psduLength = getPSDULength(cfgHE);
for j = 1:numel(cfgHE.User)
    psdu = randi([0 1],psduLength(j)*8,1,'int8');
end

% Generate and plot the waveform.

y = wlanWaveformGenerator(psdu,cfgHE);
plot(abs(y));

% Generate a full bandwidth HE MU-MIMO waveform at 80 MHz bandwidth without SIGB compression. HE-SIG-B content channel 1 has seven users. HE-SIG-B content channel 2 has zero users.

cfgHE = wlanHEMUConfig([214 115 115 115]);
cfgHE.NumTransmitAntennas = 7;

% Create PSDU data for all users.

psdu = cell(1,numel(cfgHE.User));
psduLength = getPSDULength(cfgHE);
for j = 1:numel(cfgHE.User)
    psdu = randi([0 1],psduLength(j)*8,1,'int8');
end

% Generate and plot the waveform.

y = wlanWaveformGenerator(psdu,cfgHE);
plot(abs(y))

% Copyright 2018 The MathWorks, Inc.