decode hamming code with added noise
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
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 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.
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
0 件のコメント
回答 (1 件)
Ankita Nargundkar
2017 年 6 月 21 日
For the index exceeds matrix dimensions error If you put i=1 at the top, the code will run to that point. You also get "err" = 15, and use it to index a 12x1 matrix which is the cause of the issue.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!