Main Content

gen2par

Convert between parity-check and generator matrices

Description

H = gen2par(G) converts a standard-form binary generator matrix to the corresponding parity-check matrix.

example

G = gen2par(H) converts a standard-form binary parity-check matrix to the corresponding generator matrix.

example

Examples

collapse all

Convert the parity-check matrix for a Hamming code into the corresponding generator matrix and back again.

Create the parity-check matrix.

parmat = hammgen(3)
parmat = 3×7

     1     0     0     1     0     1     1
     0     1     0     1     1     1     0
     0     0     1     0     1     1     1

Convert the parity-check matrix into the corresponding generator matrix.

genmat = gen2par(parmat)
genmat = 4×7

     1     1     0     1     0     0     0
     0     1     1     0     1     0     0
     1     1     1     0     0     1     0
     1     0     1     0     0     0     1

Convert the generator matrix back again. The output, parmat2, should be the same as the original matrix, parmat.

parmat2 = gen2par(genmat)
parmat2 = 3×7

     1     0     0     1     0     1     1
     0     1     0     1     1     1     0
     0     0     1     0     1     1     1

Input Arguments

collapse all

Generator matrix, specified as a k-by-n matrix of binary values. The standard form of a generator matrix for a [n,k] binary linear block code is [Ik P] or [P Ik], where Ik is the identity matrix of size k.

Data Types: single | double

Parity-check matrix, specified as a (n-k)-by-n matrix of binary values. The standard form of a parity-check matrix for a [n,k] binary linear block code is [-P' In-k] or [In-k -P'], where In-k is the identity matrix of size (n-k).

Data Types: single | double

Output Arguments

collapse all

Parity-check matrix, returned as a (n-k)-by-n matrix of binary values corresponding to the generator matrix G. The standard form of a parity-check matrix for a [n,k] binary linear block code is [P ' In-k] or [In-k -P '], where In-k is the identity matrix of size (n-k)

Data Types: single | double

Generator matrix, returned as a k-by-n matrix of binary values corresponding to the parity-check matrix H. The standard form of a generator matrix for a [n,k] binary linear block code is [Ik P] or [P Ik], where Ik is the identity matrix of size k.

Data Types: single | double

More About

collapse all

Generator and Parity-Check matrices

Generator matrices and parity-check matrices are parameters that are required in order to process [n,k] generic linear block codes. For more information, see Configure Parameters for Linear Block Codes.

Version History

Introduced before R2006a

See Also

|