📄 correct.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -