%% Decode LDPC Codeword
% Create transmit data consisting of two code block segments of length 2560 and 36 filler bits at the end.

C = 2;          
K = 2560;       
F = 36;    
txcbs = ones(K-F,C);
fillers = -1*ones(F,C);
txcbs = [txcbs;fillers];                

% Generate LDPC codeword for the transmit data. Use base graph number two.

bgn = 2; 
txcodedcbs = nrLDPCEncode(txcbs,bgn);   

% Convert transmit data to soft bits. Fillers in the transmit data do not have log likelihood ratio (LLR) soft bits.

rxcodedcbs = double(1-2*txcodedcbs);    
FillerIndices = find(txcodedcbs(:,1) == -1);
rxcodedcbs(FillerIndices,:) = 0;        

% Decode the encoded codeword with a maximum of 25 iterations.

[rxcbs,actualniters] = nrLDPCDecode(rxcodedcbs,bgn,25);  

% Replace filler bits with zero in transmit data and compare the results of encoding and decoding.

txcbs(end-F+1:end,:) = 0;    
isequal(rxcbs,txcbs)                
actualniters

% Copyright 2018 The MathWorks, Inc.