Low-density parity-check (LDPC) encoding
returns the LDPC-encoded output matrix for the input data matrix
out = nrLDPCEncode(
base graph number
bgn, as specified in TS 38.212 Section 5.3.2 . If applicable, the function
replaces each filler bit represented by
-1 in the input by
0. After encoding, the function replaces each filler bit again by
-1. The encoding includes puncturing of some of the systematic
Generate LDPC Codeword
Create input data for encoding consisting of two code block segments of length 2560 and 36 filler bits at the end.
C = 2; K = 2560; F = 36; cbs = ones(K-F,C); fillers = -1*ones(F,C); cbs = [cbs;fillers];
Generate LDPC codeword for the two code block segments. Use base graph number two.
bgn = 2; codedcbs = nrLDPCEncode(cbs,bgn); size(codedcbs)
ans = 1×2 12800 2
in — Code block segments before encoding
matrix | column vector
Code block segments before encoding, specified as a matrix or a column vector. The
number of columns in
in is equal to the number of scheduled code
block segments in the transport block. The number of rows in
equal to the length of the code block segment, including the filler bits, if any.
Filler bits are represented by
-1 and are treated as
0 when performing encoding.
bgn — Base graph number
1 | 2
Base graph number, specified as
values correspond to the two base graphs defined in TS 38.212 Section 5.3.2 
out — Encoded LDPC codeword
Encoded LDPC codeword output, returned as a matrix. The number of columns in
out is equal to the number of scheduled code block segments in
the transport block. The number of rows in
out is equal to the
length of the codeword. Each codeword punctures some of the systematic bits and can
contain filler bits.
 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2018b