⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linblknew.m

📁 it is the code for linear block code
💻 M
字号:
                %MATLAB PROGRAM FOR LINEAR BLOCK CODE%
                %Genarating the possible Code words & Parity Check Matrix%
                %Caliculation of dmin  %
                %Syndrome for the received code word for Eror Dection and Correction%

clc
clear all

G=input('Enter the generator matrix')
[k,n]=size(G);

disp('The possible code words are');
for i=1:2^k
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
c=rem(u*G,2)

disp('The minimum Hamming distance is');
dmin=min(sum((c(2:2^k,:))'))

disp('The parity matrix is');
P=G(1:k,(k+1):n)

I=eye(n-k,n-k);
HT=vertcat(P,I);

disp('The parity-check matrix is')
H=HT'

R=input('Enter received code word');

disp('The syndrome for the received code word is')
S =rem(R*HT,2)

for i=1:n
if S==HT(i,1:(n-k))
x=i;
end
end
disp('The error is in bit ');
x
disp('The corrected code word is ');
R(1,x) = 1 - R(1,x);
R

⌨️ 快捷键说明

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