maxt.m

来自「详细讲述纠错码的书籍」· M 代码 · 共 27 行

M
27
字号
% File: maxt.m
% Description:
% Use of the Hamming bound to determine the maximum correcting capability
% given the dimension of the code and number of redundant bits.
% Copyright (c) 2005. Robert Morelos-Zaragoza. All rights reserved.

k = input('Input the number of information bits, k = ');
r = input('Input the number of redundant bits, n-k = ');
n = k+r;

t = 0;          % Inital value of error correcting capability
test = 0;       % To test if bound is still 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
        t = t+1;
    else
        t=t-1;
        test = 1;
    end
end
fprintf('The maximum correcting capability is t = %d\n',t);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?