%% Decode PDSCH Symbols Using Configuration Parameters
% Create a carrier configuration object with default properties. Specify the physical layer cell identity as 42.

carrier = nrCarrierConfig;
carrier.NCellID = 42;

% Create a PDSCH configuration object with default properties. Set the radio network temporary identifier to 1005, size of the bandwidth part to 25, starting PRB index of the BWP to 10, and the PRB set to occupy the whole BWP.

pdsch = nrPDSCHConfig;
pdsch.RNTI = 1005;
pdsch.NID = []; % Set NID equal to the NCellID property of carrier
pdsch.NSizeBWP = 25;
pdsch.NStartBWP = 10;
pdsch.PRBSet = 0:pdsch.NSizeBWP-1;

% Generate PDSCH symbols for a single codeword of 8000 bits with the specified carrier configuration and PDSCH configuration.

cws = randi([0 1],8000,1);
sym = nrPDSCH(carrier,pdsch,cws);

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

SNR = 30; % SNR in dB
rxsym = awgn(sym,SNR);
[rxbits,symbols] = nrPDSCHDecode(carrier,pdsch,rxsym);

% Copyright 2019 The MathWorks, Inc.