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.
decode hamming code with added noise
3 次查看(过去 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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Hamming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!