加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

汉明码编码译码

(2012-07-18 14:49:42)
标签:

汉明码

hamming

code

杂谈

分类: 通信原理MATLAB仿真

The execution of this MATLAB program will generate the following results, which include the

erroneous codeword, the syndrome, the error pattern, and the corrected codeword.

http://s11/middle/59a069d5nc515146da74a&690

% Chapter 15 Error Correcting Codes
%
% In our next exercise, we provide a program to decode the(7,4)
% Hamming code of Example 15.3.
%
% Matlab Program < Ex15_3.m >
% to illustrate encoding and decoding of Hamming (7,4) code
%
G=[1 0 0 0 1 0 1      % Code Generating Matrix
   0 1 0 0 1 1 1
   0 0 1 0 1 1 0
   0 0 0 1 0 1 1];
H=[G(:,5:7)', eye(3,3)];    % Parity Check Matrix
E=[1 0 0 0 0 0 0      % List of correctable errors
   0 1 0 0 0 0 0
   0 0 1 0 0 0 0
   0 0 0 1 0 0 0
   0 0 0 0 1 0 0
   0 0 0 0 0 1 0
   0 0 0 0 0 0 1];
K=size(E,1);
Syndrome=mod(mtimes(E,H'),2);   % Find Syndrome List
r=[1 0 1 0 1 1 1]               % Received codeword
display(['Syndrome ','Error Pattern'])
display(num2str([Syndrome E]))
x=mod(r*H',2);                  % Compute syndrome
for kk=1:K,
    if Syndrome(kk,:)==x,
        idxe=kk;
    end
end
syndrome=Syndrome(idxe,:)       % display the syndrome
error=E(idxe,:)
cword=xor(r,error)              % Error correction

%------------------------------------------------------------
% 参考文献

% B.P.拉兹,丁峙. 现代数字与模拟通信系统[M]. 第4版. 北京:电子工业出版社,2011:967-968

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有