%% Decode UCI Codeword with 16-QAM Modulation Scheme and AWGN
% Create a random sequence of binary values corresponding to a two-bit UCI message.

K = 2;
uci = randi([0 1],K,1,'int8');

% Encode the message for the specified length of the rate-matched output and 16-QAM modulation scheme.

mod = '16QAM';
E = 4*3;
encUCI = nrUCIEncode(uci,E,mod);

% Replace placeholders -1 and -2 in the output through scrambling.

encUCI(encUCI==-1) = 1;
encUCI(encUCI==-2) = encUCI(find(encUCI==-2)-1);

% Modulate the encoded UCI message.

modOut = nrSymbolModulate(encUCI,mod);

% Add white Gaussian noise (AWGN) to the modulated symbols using a signal-to-noise ratio of 0 dB.

snrdB = 0;
rxSig = awgn(modOut,snrdB);

% Demodulate the received signal.

rxSoftBits = nrSymbolDemodulate(rxSig,mod);

% Decode the soft bits representing the demodulated UCI codeword.

decBits = nrUCIDecode(rxSoftBits,K,mod);

% Verify that the transmitted and received message bits are identical.

isequal(decBits,uci) 

% Copyright 2018-2019 The MathWorks, Inc.