correct.m

来自「Digital communication labs,」· M 代码 · 共 38 行

M
38
字号
function [corrected]=correct(G,n,k,received);

p=G(1:k,1:n-k);     % creating the parity matrix from the G matrix

h=[eye(n-k) p'];    % creating the H Matrix

trans_h= h';        % creating the H transpose matrix by transposing the H matrix

s=received * trans_h; % calculating the syndrome vector S

for i=1:n-k,

    if rem(s(1,i),2)==0,
        s(1,i)=0;
    else s(1,i)=1;
    end
end

x=zeros(1,n);

if s==zeros(1,n-k),
    e=zeros(1,n);
else for i=1:n,
            if s == trans_h(i,1:n-k),
                x(1,i)=1;
                e=x;
            end
        end
    end
    %end
    
 corrected1=received+e;      % these are received bits + error bits
for i=1:n,
    if corrected1(1,i)==2;
        corrected1(1,i)=0;
    end
end
corrected=corrected1;     % CORRECTED BITS

⌨️ 快捷键说明

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