minred.m
来自「详细讲述纠错码的书籍」· M 代码 · 共 25 行
M
25 行
% File: minred.m
% Description:
% Use of the Hamming bound to find the number of redundant bits given
% the dimension of the code and desired error correcting capability.
% Copyright (c) 2005. Robert Morelos-Zaragoza. All rights reserved.
k = input('Input the number of information bits, k = ');
t = input('Input the desired error correcting capability, t = ');
n = k+1; % Inital value of length
test = 0; % To test if bound is satisfied
while test ~= 1
% Compute the volume of a Hamming sphere of radius t
S = 0;
for i=0:t
S = S + nchoosek(n,i);
end
% Compare with the number of syndromes
if 2^(n-k) >= S
test = 1;
else
n = n+1;
end
end
fprintf('The minimum number of redundant bits is n-k = %d\n',n-k);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?