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!
5, oru(5) = 0.7would be considered the highest value and that is not correct. It's actually the last value, so that's 7 and thusu(7) = 1.5. Double check your expected vectorpand 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.