title: How to make a parity check matrix from non-systematic to systematic in Matlab? thanks
body: <p>I am trying to make a parity check matrix from non-systematic to systematic. Hence, I am attaching my code below. Somewhat it is correct, but there are some problems. It would be really great if someone could help me in this.</p>
  <p>Subject: Information theory and coding. I am working on LDPC coding and decoding. Please check the code below</p>
  <p>MATLAB CODE:</p>
  <pre><code>H = [1 0 1 1 0; 0 0 1 0 1; 1 0 0 1 0; 1 0 1 1 1]
  
  [m,n] = size(H);
  k = n-m;
  for i = k+1:n
  %H(:,i)
  ind = find(H(:,i),1,'last');
  % exchanging (ind)th row and (i-k)th row
  if ind &lt; i-k
      continue;
  end
  if ind ~= i-k
      temp = H(ind,:);
      H(ind,:) = H(i-k,:);
      H(i-k,:) = temp;
  end
  I = find(H(:,i));
  % Guassian elimination
  for j = 1:length(I)
      if I(j) ~= i-k
          H(I(j),:) = mod(H(I(j),:)+H(i-k,:),2);
      end
  end
  end
  Hsys = H
  </code></pre>
  <p>For e.g.</p>
  <p>This is my <code>H</code> matrix:</p>
  <pre><code>H =
  
      1     0     1     1     0
      0     0     1     0     1
      1     0     0     1     0
      1     0     1     1     1
  </code></pre>
  <p>I want to have an identity matrix inside the matrix. The dimension on <code>H</code> matrix here is (<code>mxn</code>) which is (<code>4x5</code>).</p>
  <p>Generally we use Gaussian elimination method to make the Identity matrix.hence, we make operations between rows. This is how we make it systematic.
  I should have matrix as this in the result:</p>
  <pre><code>Hsys =
  
         0     1     0     0     0
         0     0     1     0     0
         1     0     0     1     0
         0     0     0     0     1
  </code></pre>
  <p><img src="https://i.stack.imgur.com/2LPc4.jpg" alt="enter image description here" /></p>
  <p>I should have an identity matrix of dimension <code>m</code>.</p>