decode hamming code with added noise

Thread Starter

digitsboy

Joined Dec 29, 2016
48
I hope someone can help me here and i hope i post it on the right place haha

i made a function to decode hamming and a function to encode hamming. I used (11,7) hamming(to understand hamming, i don't want to use the standard matlab function) First i encoded the 7 bit sequence after that i added noise by making use of awgn function in matlab and after that i decoded the hamming.

for example 1001101 becomes: 011100101010 the last parity bit is checking even parity

The problem is with decoding i used 5 parity bits for checking errors. After multiplying the parity checking matrix with the 11 bit matrix i get a 5 bit matrix. The last bit is checking even parity. If so, no error occured. If it's not even parity then there is an error. The first 4 bits are giving the place were the error is. The strange thing is that sometimes it says the error is at place 15 for example? and then i get an error like index exceeds matrix dimensions.

i don't know how to fix this. here i gave a piece of the code with the input(with added noise) were it goes wrong.

Code:
input=[1;1;1;0;1;0;0;0;0;1;0;0]
paritycheck =[1 0 1 0 1 0 1 0 1 0 1 0;0 1 1 0 0 1 1 0 0 1 1 0;0 0 0 1 1 1 1 0 0 0 0 0;0 0 0 0 0 0 0 1 1 1 1 0; 1 1 1 1 1 1 1 1 1 1 1 1];
y = mod(paritycheck*input,2);
err = y(1,i)+2*y(2,i)+4*y(3,i)+8*y(4,i)
%nonerror
if err == 0 && y(5,i) == 0
corr = input;
%doubele err
elseif err > 0 && y(5,i) == 0
corr = input;
%single err
elseif y(5,i) == 1 && err > 0
%change value of bit
if input(err,i) == 1
input(err,i) = 0;
else
input(err,i) = 1;
end
corr = input;
%err in last parity bit
elseif err == 0 && y(5,i) == 1
corr = input;
else
corr = input;
end
 
Last edited:

BR-549

Joined Sep 22, 2013
4,928
Thank's digitsboy.....that was quite a read. Don't take this the wrong way....but I'm glad I can't help you.
Makes me dizzy.

Have some patience........there are experts on here that will help you.
 

Thread Starter

digitsboy

Joined Dec 29, 2016
48
http://users.cis.fiu.edu/~downeyt/cop3402/hamming.html

"A byte of data: 10011010"
"Code word: 011100101010"
thanks for your reaction!
Encoding is no problem, it's about decoding!

The matlab code gives an error by decoding for example:
input=[1;1;1;0;1;0;0;0;0;1;0;0]
because it gives an error at the 15th place and that is impossible

the first,second,fourth and eight and twelfth are parity bits. The last one is used to check even parity
 
Top