htruthtb.m

来自「数字通信第四版原书的例程」· M 代码 · 共 39 行

M
39
字号
function trt = htruthtb(g)
%HTRUTHTB Generates a Hamming code truth table.
%       TRT = HTRUTHTB(G) produces a truth table for single error-correction
%       code. The size of G has the dimension defined in Hamming coding.
%
%       See also: HAMMGEN, DECODE.

%       Wes Wang 6/17/94, 10/10/95
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 18:01:05 $

[k, n] = size(g);
if k > n
    g = g';
     [k, n] = size(g);
end;

if max(max(eye(k) - g(:, n-k+1:n))) > 0
    h = g;
else
    h = gen2par(g);
    [k, n] = size(h);
end;

if max(max(eye(k) - h(:, 1:k))) > 0
    error('The input matrix is neither generator or parity-check matrix')
end;

%construct a truth table
trt = [zeros(1, n); eye(n)];
hh = [zeros(1,k); fliplr(h')];

% reorder the truth table based on h.
hh = bi2de(hh)+1;
%trt(hh,:) = trt(hh, :);
trt(hh,:) = trt;

%--end of htruthtb--

⌨️ 快捷键说明

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