Main Content

comm.LDPCEncoder

(To be removed) Encode binary low-density parity-check (LDPC) code

comm.LDPCEncoder will be removed in a future release. Use ldpcEncode instead. (since R2021b) For more information on updating your code, see Version History.

Description

The comm.LDPCEncoder System object™ applies LDPC coding to a binary input message. LDPC codes are linear error control codes with sparse parity-check matrices and long block lengths that can attain performance near the Shannon limit.

To encode a binary LDPC code:

  1. Create the comm.LDPCEncoder object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

example

ldpcencoder = comm.LDPCEncoder creates a binary LDPC encoder System object. This object performs LDPC encoding based on the default parity-check matrix.

ldpcencoder = comm.LDPCEncoder(parity) sets the ParityCheckMatrix property to parity and creates an LDPC encoder System object. The parity input must be specified as described by the ParityCheckMatrix property.

ldpcencoder = comm.LDPCEncoder(___,Name,Value) sets properties using one or more name-value pairs, in addition to inputs from any of the prior syntaxes. For example, comm.LDPCEncoder('ParityCheckMatrix',sparse(I(:,1),I(:,2),1)) configures an LDPC encoder System object to encode data using the parity matrix sparse(I(:,1),I(:,2),1). Enclose each property name in quotes.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Parity-check matrix, specified as a sparse (NK)-by-N binary-valued matrix. N is the length of the output codeword vector, and must be in the range (0, 231). K is the length of the uncoded message and must be less than N. The last (NK) columns in the parity-check matrix must be an invertible matrix in the Galois field of order 2, gf(2).

You can also specify the parity-check matrix as a two-column nonsparse index matrix, I, that defines the row and column indices of the 1s in the parity-check matrix such that sparse(I(:,1),I(:,2),1).

This property accepts numeric data types. When you set this property to a sparse binary matrix, this property also accepts the logical data type.

The default value uses the dvbs2ldpc function to configure a sparse parity-check matrix for half-rate LDPC coding, as specified in the DVB-S.2 standard.

Note

  • When the last (NK) columns of the parity-check matrix form a triangular matrix, forward or backward substitution is performed to solve the parity-check equation.

  • When the last (NK) columns of the parity-check matrix do not form a triangular matrix, a matrix inversion is performed to solve the parity-check equation. If a large matrix needs to be inverted, initializations or updates take more time.

Example: dvbs2ldpc(R,'indices') configures the index matrix for the DVB-S.2 standard, where R is the code rate, and 'indices' specifies the output format of dvbs2ldpc as a two-column double-precision matrix that defines the row and column indices of the 1s in the parity-check matrix.

Data Types: double | logical

Usage

Description

example

codeword = ldpcencoder(message) codes the input message using an LDPC code based on a parity-check matrix. The LDPC codeword output is a solution to the parity-check equation.

Input Arguments

expand all

Input message, specified as a K-by-1 column vector containing binary-valued elements. K is the length of the uncoded message.

Data Types: double | logical

Output Arguments

expand all

LDPC codeword, returned as an N-by-1 column vector. N is the number of bits in the LDPC codeword. The output signal inherits its data type from the input signal. The LDPC codeword output is a solution to the parity-check equation. The input message comprises the first K bits of the LDPC codeword output, and the parity check comprises the remaining (NK) bits.

Data Types: double | logical

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Transmit an LDPC-encoded, QPSK-modulated bit stream through an AWGN channel. Demodulate and decode the received signal. Compute the error statistics for the reception of uncoded and LDPC-coded signals.

Define simulation variables. Create System objects for the LDPC encoder, LDPC decoder, QPSK modulator, and QPSK demodulators.

M = 4; % Modulation order (QPSK)
snr = [0.25,0.5,0.75,1.0,1.25];
numFrames = 10;
ldpcEncoder = comm.LDPCEncoder;
ldpcDecoder = comm.LDPCDecoder;
pskMod = comm.PSKModulator(M,'BitInput',true);
pskDemod = comm.PSKDemodulator(M,'BitOutput',true,...
    'DecisionMethod','Approximate log-likelihood ratio');
pskuDemod = comm.PSKDemodulator(M,'BitOutput',true,...
    'DecisionMethod','Hard decision');
errRate = zeros(1,length(snr));
uncErrRate = zeros(1,length(snr));

For each SNR setting and all frames, compute the error statistics for uncoded and LDPC-coded signals.The outer for loop processes each SNR value. The inner for loop processes frames of input data.

for ii = 1:length(snr)
    ttlErr = 0;
    ttlErrUnc = 0;
    pskDemod.Variance = 1/10^(snr(ii)/10);
    for counter = 1:numFrames
        data = logical(randi([0 1],32400,1));
        % Transmit and receiver uncoded signal data
        mod_uncSig = pskMod(data);
        rx_uncSig = awgn(mod_uncSig,snr(ii),'measured');
        demod_uncSig = pskuDemod(rx_uncSig);
        numErrUnc = biterr(data,demod_uncSig);
        ttlErrUnc = ttlErrUnc + numErrUnc;
        % Transmit and receive LDPC coded signal data
        encData = ldpcEncoder(data);
        modSig = pskMod(encData);
        rxSig = awgn(modSig,snr(ii),'measured');
        demodSig = pskDemod(rxSig);
        rxBits = ldpcDecoder(demodSig);
        numErr = biterr(data,rxBits);
        ttlErr = ttlErr + numErr;
    end
    ttlBits = numFrames*length(rxBits);
    uncErrRate(ii) = ttlErrUnc/ttlBits;
    errRate(ii) = ttlErr/ttlBits;
end

Run this code to plot the error statistics for uncoded and LDPC-coded data.

plot(snr,uncErrRate,snr,errRate)
legend('Uncoded','LDPC coded')
xlabel('SNR (dB)')
ylabel('BER')

Extended Capabilities

Version History

Introduced in R2012a

expand all

R2023b: To be removed

comm.LDPCEncoder will be removed. Use ldpcEncode instead. To specify the LDPC code applied by the ldpcEncode function, use the configuration object returned by ldpcEncoderConfig.

The code in this table shows LDPC encoding of data using the recommended function and configuration object.

Discouraged FeatureRecommended Replacement
% Encode using parity-check matrix (pcmatrix)
enc = comm.LDPCEncoder(pcmatrix);
codeword = enc(infoBits);
% Encode using parity-check matrix (pcmatrix)
cfg = ldpcEncoderConfig(pcmatrix);
codeword = ldpcEncode(infoBits,cfg);