%% Decode PUSCH Symbols using Configuration Parameters
% Create a carrier configuration object with physical layer cell identity as 42.

carrier = nrCarrierConfig;
carrier.NCellID = 42;

% Create a PUSCH configuration object with these properties.

pusch = nrPUSCHConfig;
pusch.Modulation = '256QAM';
pusch.NumLayers = 2;
pusch.RNTI = 111;
pusch.TransformPrecoding = 0;
pusch.TransmissionScheme = 'nonCodebook';
pusch.NID = []; % Use empty to be equal to NCellID of carrier
pusch.NSizeBWP = 25;
pusch.NStartBWP = 10;
pusch.PRBSet = 0:pusch.NSizeBWP-1; % Occupy entire bandwidth part

% Generate PUSCH symbols for a single codeword of 8064 bits with the specified carrier configuration and uplink shared channel configuration.

cw = randi([0 1],8064,1);
sym = nrPUSCH(carrier,pusch,cw)

% Add an additive white Gaussian noise (AWGN) to the PUSCH symbols. Then demodulate to produce soft bit estimates.

SNR = 30; % SNR in dB
rxsym = awgn(sym,SNR);
demod = nrPUSCHDecode(carrier,pusch,rxsym)

% Perform hard decision on the soft metric.

rxcw = double(demod<0);

% Compare the result with the original codeword.

isequal(cw,rxcw)

% Copyright 2019 The MathWorks, Inc.