Main Content

ldpcEncode

Encode binary LDPC code

Description

example

y = ldpcEncode(informationbits,encodercfg) encodes the input message, informationbits, using the LDPC matrix specified by the LDPC encoder configuration object, encodercfg. The output LPDC codeword contains the information bits followed by the parity-check bits. LDPC codes are linear error control codes with sparse parity-check matrices and long block lengths that can attain performance near the Shannon limit.

y = ldpcEncode(informationbits,encodercfg,OutputFormat=fmt) specifies the output format of the codeword.

Examples

collapse all

Initialize parameters for the prototype matrix and block size to configure a rate 3/4 LDPC code specified in IEEE 802.11. Create the parity-check matrix by using the ldpcQuasiCyclicMatrix function.

P = [16 17 22 24  9  3 14 -1  4  2  7 -1 26 -1  2 -1 21 -1  1  0 -1 -1 -1 -1
     25 12 12  3  3 26  6 21 -1 15 22 -1 15 -1  4 -1 -1 16 -1  0  0 -1 -1 -1
     25 18 26 16 22 23  9 -1  0 -1  4 -1  4 -1  8 23 11 -1 -1 -1  0  0 -1 -1
      9  7  0  1 17 -1 -1  7  3 -1  3 23 -1 16 -1 -1 21 -1  0 -1 -1  0  0 -1
     24  5 26  7  1 -1 -1 15 24 15 -1  8 -1 13 -1 13 -1 11 -1 -1 -1 -1  0  0
      2  2 19 14 24  1 15 19 -1 21 -1  2 -1 24 -1  3 -1  2  1 -1 -1 -1 -1  0
    ];
blockSize = 27;
pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);

Create an LDPC encoder configuration object, displaying its properties. Generate random information bits by using the NumInformationBits property of the configuration object to specify the number of information bits in an LPDC codeword. Encode the information bits by the LDPC code specified by the LDPC encoder configuration object.

cfgLDPCEnc = ldpcEncoderConfig(pcmatrix)
cfgLDPCEnc = 
  ldpcEncoderConfig with properties:

     ParityCheckMatrix: [162x648 logical]

   Read-only properties:
           BlockLength: 648
    NumInformationBits: 486
    NumParityCheckBits: 162
              CodeRate: 0.7500

infoBits = rand(cfgLDPCEnc.NumInformationBits,1) < 0.5;
codeword = ldpcEncode(infoBits, cfgLDPCEnc);

Input Arguments

collapse all

Information bits, specified as a matrix. The number of rows in informationbits must equal the value of the NumInformationBits property of the input encodercfg.

Data Types: single | double | int8 | logical

LDPC encoder configuration, specified as an ldpcEncoderConfig object.

Output format, specified as one of these values:

  • 'whole' — Output the whole LDPC codeword, including information bits and parity-check bits. The number of rows that the function outputs equals the value of theBlockLength property for the input encodercfg.

  • 'parity' — Output only the parity-check bits. The number of rows that the function outputs equals the value of the NumParityCheckBits property for the input encodercfg.

Output Arguments

collapse all

Encoded codeword, returned as a matrix. For the encoding operation, the function encodes each column of the input informationbits independently. The function treats nonzero values in informationbits as ones. The encoding computes a systematic codeword matrix populated with the original information bits in the [1:K,:] submatrix and the parity-check bits in the ((1:K + 1):end,:) submatrix. K equals the NumInformationBits property of the input encodercfg.

  • When the output format is 'whole', the output contains the whole LDPC codeword, including the information bits and the parity-check bits. The number of rows output by the function equals the value of the BlockLength property for the input encodercfg.

  • When the output format is 'parity', the output contains only the parity-check bits. The number of rows that the function outputs equals the NumParityCheckBits property for the input encodercfg.

For information about setting the output format, see the OutputFormat argument. The output has the same data type as the input informationbits.

References

[1] IEEE Std 802.11™-2016 (Revision of IEEE Std 802.11-2012). "Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications." IEEE Standard for Information technology — Telecommunications and information exchange between systems. Local and metropolitan area networks — Specific requirements.

[2] Gallager, Robert G. Low-Density Parity-Check Codes. Cambridge, MA: MIT Press, 1963.

Extended Capabilities

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

Introduced in R2021b