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!