Main Content

ldpcEncoderConfig

Create LDPC encoder configuration

Since R2021b

Description

The ldpcEncoderConfig object is a configuration object for the ldpcEncode function. The object specifies the low-density parity-check (LDPC) matrix and read-only properties to provide information about the configured matrix.

Creation

Description

encodercfg = ldpcEncoderConfig creates an LDPC encoder configuration object that specifies a rate 5/6 LDPC code from the WLAN 802.11™ standard [1].

encodercfg = ldpcEncoderConfig(H) configures the output object setting the ParityCheckMatrix property to H.

example

encodercfg = ldpcEncoderConfig(decodercfg) sets properties based on the input ldpcDecoderConfig configuration object, decodercfg.

Validation of the object settings is performed when the ldpcEncode function is called with the object as an input.

Properties

expand all

Parity-check matrix, specified as a sparse logical (NK)-by-N matrix, where N > K > 0. The last NK rows of the parity-check matrix must be invertible in a Galois field of order 2. N is the LDPC codeword block length. K is the number of information bits in the LDPC codeword. The default is the parity-check matrix of rate 5/6 LDPC code with a block length of 648 as specified in the WLAN 802.11 standard [1]. Specifically, the default is the sparse logical 108-by-648 matrix H output by the ldpcQuasiCyclicMatrix function in this code.

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

Data Types: logical

This property is read-only.

Block length of the LDPC codeword (N), specified as a positive scalar. N equals the number of columns in the parity-check matrix.

Data Types: double

This property is read-only.

Number of information bits in the LDPC codeword (K), specified as a positive scalar. K equals the number of columns of the parity-check matrix minus the number of rows of the parity-check matrix.

Data Types: double

This property is read-only.

Number of parity-check bits in the LDPC codeword (NK), specified as a positive scalar. NK equals the number of rows in the parity-check matrix.

Data Types: double

This property is read-only.

Code rate of the LDPC code, specified as a positive scalar that is equal to NumInformationBits/BlockLength.

Data Types: double

LDPC encoder configuration object, returned as a structure.

Data Types: struct

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 LDPC encoder and decoder configuration objects, displaying their properties.

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

     ParityCheckMatrix: [162×648 logical]

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

cfgLDPCDec = ldpcDecoderConfig(pcmatrix)
cfgLDPCDec = 
  ldpcDecoderConfig with properties:

     ParityCheckMatrix: [162×648 logical]
             Algorithm: 'bp'

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

Transmit an LDPC-encoded, M-QAM-modulated bit stream through an AWGN channel. Demodulate the signal, decode the received codewords, and then count bit errors. Use a for loop to process multiple SNR settings with and without LDPC forward error correction (FEC) coding of the transmitted data.

M = 64;
maxnumiter = 10;
snr = [0.5 1 1.5 2];
numframes = 20000;

for ii = 1:length(snr)
    data = randi([0 1],cfgLDPCEnc.NumInformationBits,numframes,'int8');

    % Transmit and receive with LDPC coding
    encodedData = ldpcEncode(data,cfgLDPCEnc);
    modSignal = qammod(encodedData,M,InputType='bit');
    [rxsig, noisevar] = awgn(modSignal,snr(ii));
    llrOut = qamdemod(rxsig,M, ...
        OutputType='approxllr', ... % Or use 'llr' for exact but slower LLR calculation
        NoiseVariance=noisevar);
    rxbits = ldpcDecode(llrOut,cfgLDPCDec,maxnumiter);
    fprintf(['SNR = %2.1f\n   Coded: Error rate = %1.6f, ' ...
        'Number of errors = %d\n'], ...
        snr(ii),nnz(data~=rxbits)/numel(data),nnz(data~=rxbits));

    % Transmit and receive with no LDPC coding
    noCoding = qammod(data,M,InputType='bit');
    rxNoCoding = awgn(noCoding,snr(ii));
    rxBitsNoCoding = qamdemod(rxNoCoding,M,OutputType='bit');

    fprintf(['Noncoded: Error rate = %1.6f, ' ...
        'Number of errors = %d\n\n'], ...
        nnz(data~=rxBitsNoCoding)/numel(data),nnz(data~=rxBitsNoCoding))
end
SNR = 0.5
   Coded: Error rate = 0.000441, Number of errors = 4282
Noncoded: Error rate = 0.039045, Number of errors = 379515
SNR = 1.0
   Coded: Error rate = 0.000062, Number of errors = 604
Noncoded: Error rate = 0.032813, Number of errors = 318941
SNR = 1.5
   Coded: Error rate = 0.000003, Number of errors = 27
Noncoded: Error rate = 0.027001, Number of errors = 262450
SNR = 2.0
   Coded: Error rate = 0.000000, Number of errors = 0
Noncoded: Error rate = 0.021778, Number of errors = 211686

References

[1] IEEE® Std 802.11-2020 (Revision of IEEE Std 802.11-2016). "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.

Extended Capabilities

expand all

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

Version History

Introduced in R2021b