I want to convert the following parity-check matrix into Generator matrix.

47 views (last 30 days)
t=
[1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0;
0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0;
0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0;
0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0;
0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1;
1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1;
0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0;
0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0;
0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0;
0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0;
1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0;
0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0;
0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0;
0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1;
0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0]

Answers (1)

prabhat kumar sharma
prabhat kumar sharma on 15 Jan 2024
Hi Jasvinder,
I Understand you are facing issue with creating the generator matrix from the parity check matrix.
One way is to use predefined functions matlab provides.
While the another way is :
To convert the given parity-check matrix (H) into a generator matrix (G), we need to find a matrix (G) such that (GH^T = 0).
The given matrix (H) is structured with identity matrices along the diagonal, which suggests that it is already in a form similar to the standard form ([P | I_{n-k}]). However, the identity matrices are not isolated to the right side of (H), so we need to rearrange (H) such that the identity matrices form a block on the right side of (H).
The given (H) matrix is a (15 \times 20) matrix, which indicates that the code is a ([20, 5]) code (since (n - k = 15), the number of rows in (H), and (n = 20), the number of columns in (H)). Therefore, (k), the dimension of the message vector, is (20 - 15 = 5).
The first step is to identify the columns that will form the ((n-k) \times (n-k)) identity matrix after rearrangement. In this case, it looks like the columns that need to be moved to form the identity matrix on the right are columns 6, 8, 10, 12, 14, 16, 18, and 20 (since they contain the identity matrices scattered throughout (H)).
Once we have identified these columns, we can perform column swaps to move them to the right side of (H). After rearranging, the matrix (H) should look like ([P | I_{n-k}]).
function temp(H)
[m, n] = size(H);
k = n - m;
% Perform Gaussian elimination to get H into [P | I_(n-k)] form
% Since we are working in GF(2), we need to make sure all operations are mod 2
H_mod2 = mod(H, 2);
[H_row_reduced, pivot_columns] = rref(H_mod2);
H_row_reduced = mod(H_row_reduced, 2); % Ensure the result is in GF(2)
% Find non-pivot columns (these will form the P matrix in G)
non_pivot_columns = setdiff(1:n, pivot_columns);
% Rearrange the columns of H so that the identity matrix is on the right
H_standard_form = H_row_reduced(:, [non_pivot_columns pivot_columns]);
% Extract P from the rearranged H
P = H_standard_form(:, 1:k);
% Construct G from P in systematic form [I_k | P^T]
G = [eye(k), P'];
G = mod(G, 2) % Ensure the result is in GF(2)
end
I hope it helps !

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!