Main Content


Low-density parity-check (LDPC) rate recovery



out = nrRateRecoverLDPC(in,trblklen,R,rv,mod,nLayers) returns the rate-recovered output representing the LDPC-encoded code blocks for input data vector in. The input trblklen is the transport block length, R is the target code rate, rv is the redundancy version, mod is the modulation type, and nLayers is the number of transmission layers. The internal buffer used for the soft input has no size limits, and the output contains the total number of code blocks.

nrRateRecoverLDPC is the inverse of nrRateMatchLDPC and performs the inverse of the code block concatenation, bit interleaving, and bit selection stages at the receiver end.

out = nrRateRecoverLDPC(___,numCB) specifies the number of code blocks numCB to be recovered, in addition to the input arguments in the previous syntax.

out = nrRateRecoverLDPC(___,numCB,Nref) returns the rate-recovered output for a limited soft buffer size Nref with the specified number of code blocks numCB to recover, in addition to the input arguments in the first syntax. Nref is defined in TS 38.212 Section [1].


collapse all

Create input data of length 4500 corresponding to soft bits. The length of the original transport block is 4000. Perform LDPC rate recovery of the input to one code block. Use single transmission layer with QPSK modulation and zero redundancy version.

sbits = ones(4500,1);
trblklen = 4000;    
R = 0.5;                
rv = 0;                 
mod = 'QPSK';           
nlayers = 1;            
numCB = 1;              
raterec = nrRateRecoverLDPC(sbits,trblklen,R,rv,mod,nlayers,numCB);
ans = 1×2

       12672           1

Input Arguments

collapse all

Received soft bits before code block desegmentation, specified as a vector.

Data Types: double | single

Original transport block length, specified as a nonnegative integer.

Data Types: double

Target code rate, specified as a real scalar in the range (0,1).

Data Types: double

Redundancy version, specified as an integer from 0 to 3.

Data Types: double

Modulation scheme, specified as 'pi/2-BPSK', 'QPSK', '16QAM', '64QAM', '256QAM', or '1024QAM'. This modulation scheme determines the modulation type of the codeword and the number of bits used per modulation symbol.

Modulation SchemeNumber of Bits Per Symbol



Data Types: char | string

Number of transmission layers associated with the transport block, specified as an integer from 1 to 4.

Data Types: double

Number of scheduled code block segments, specified as a positive integer. numCB is less than or equal to the number of code block segments for a transport block.

Data Types: double

Limited buffer rate matching, specified as a positive integer. Nref is defined in TS 38.212 Section

Data Types: double

Output Arguments

collapse all

Rate-recovered scheduled code segments, returned as a matrix. The number of rows in out is calculated from trblklen and R. The number of columns in out is equal to numCB, or the total number of code blocks for a transport block. Filler bits are set to Inf to correspond to zeros used during their encoding.

Data Types: double | single


[1] 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018b

expand all