0

I have a binary Hamming code with generator matrix

 G = [1 0 0 0 1 0 1;
      0 1 0 0 1 1 1;
      0 0 1 0 1 1 0;
      0 0 0 1 0 1 1];

and u is a received vector u = [0.5 0.3 1.3 -0.1 0.7 0.6 1.5].

The permutation received vector based on decreasing values is :

v = p(u) = [1.5 1.3 0.7 0.6 0.5 0.3 -0.1] with p = (5 6 2 7 3 4 1).

The permuted generator matrix is :

G1 = [1 0 1 0 1 0 0;
      1 0 1 1 0 1 0;
      0 1 1 1 0 0 0;
      1 0 0 1 0 0 1];

I tried to program this example but I do not find exactly the same answer, I find p different but the same v and G1.

My code :

G = [1 0 0 0 1 0 1;
     0 1 0 0 1 1 1;
     0 0 1 0 1 1 0;
     0 0 0 1 0 1 1];

u = [0.5 0.3 1.3 -0.1 0.7 0.6 1.5];
[~,p] = sort(u,'descend');
v = u(p);
G1 = G(:,[p]);

I obtain :

v = [1.5 1.3 0.7 0.6 0.5 0.3 -0.1];
p = [7 3 5 6 1 2 4]; 

G1 = [1 0 1 0 1 0 0;
      1 0 1 1 0 1 0;
      0 1 1 1 0 0 0;
      1 0 0 1 0 0 1];

What is the problem in my code? I would like to have the same results as in the example.

Thanks!

3
  • Where is the example from? Commented Jun 28, 2017 at 14:26
  • 1
    The permutation vector that you propose is incorrect. What MATLAB gives is the right result if you are looking for the indices based on decreasing values. In your answer, location 5, or u(5) = 0.7 would be considered the highest value and that is not correct. It's actually the last value, so that's 7 and thus u(7) = 1.5. Double check your expected vector p and make sure it aligns with your definition of "decreasing values". If not, please edit your post to reveal the true nature of this permutation vector. Commented Jun 28, 2017 at 14:40
  • Thanks rayryeng - Reinstate Monica. Commented Dec 27, 2019 at 23:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.