当前位置:文档之家› 实验6-BCH循环码的编码与译码的matlab实现

实验6-BCH循环码的编码与译码的matlab实现

实验6 BCH循环码的编码与译码
一、实验内容
用VC或Matlab软件编写循环BCH码的编码与译码程序。

利用程序对教科书的例题做一个测试。

二、实验环境
1.计算机
2.Windows 2000 或以上
3.Microsoft Visual C++ 或以上
4.Matlab 或以上
三、实验目的
1.通过BCH循环码的编码与译码程序的编写,彻底了解并掌握循环BCH的编码与译码原理
2.通过循环BCH码的编码与译码程序的编写,提高编程能力。

四、实验要求
1.提前预习实验,认真阅读实验原理以及相应的参考书。

2.对不同信道的进行误码率分析。

特别是对称信道,画出误码性能图。

即信道误码率与循环汉明码
之间的关系。

3.认真填写实验报告。

五、实验原理
1.循环BCH的编码与译码原理(略)
2.循环BCH的程序实现。

六、实验步骤
文件
function bch_en_decode()
code=bch155
code=code+randerr(5,15,1:3);
code=rem(code,2);
code=gf(code) %随机产生1-3位错误
decode=debch155(code)
end
function decode=debch155(code)
code=gf(code);
M=4;
code = gf,M);
[m , n]=size(code);decode=[];
code1=[];
for i=1:m ;code1=code(i,:);
M=;T2=6;N=15;
S = code1* ((gf(2,M,).^([N-1:-1:0]'*([1:T2])));
LambdaX = gf([1 zeros(1,T2)],M,;
Tx = [0 1 zeros(1,T2-1)];
L=0;
for k = 1:T2;
LambdaXTemp = LambdaX;
Delta = S(k) - LambdaXTemp(1+[1:L])*(S(k-[1:L]))';
if ;
LambdaX = LambdaXTemp - Delta*Tx;
if 2*L < k;
L = k-L;
Tx = LambdaXTemp/Delta;
end;
end;
Tx = [0 Tx(1:T2)];
end;
LambdaXValue = ;
LambdaX = gf(LambdaXValue(1:max(find(LambdaXValue))), M, ;
errLoc_int = roots(LambdaX);errLoc = log(errLoc_int);
for i = 1:length(errLoc);
errorMag = 1;
code1(N-errLoc(i)) = code1(N-errLoc(i)) - errorMag;
end;
decode=[decode;code1]; end;
ccode = gf;
decoded = ccode(:,1:5);
end
function [yout]=bch155(x) %定义函数
k=5; %信息码位,BCH(15,5)
if nargin<1
x2=randint(5,k);
n=5;
msg=x2 %判断输入信息 ,若未输入,系统自动产生5组信息码,并显示出信息位
elseif rem(length(x),k)==0;n=length(x)/k;x2=[]; %判断msg是否为K的整数倍,并把输入码员分组for i=0:n-1
x2=[x2;x(i*k+1) x(i*k+2) x(i*k+3) x(i*k+4) x(i*k+5)];
end
if rem(length(x),k)>0 %把输入码员补零并分组
x=[x,zeros(size(1:k-rem(length(x),k)))];
n=length(x)/k;x2=[];
for i=0:n-1
x2=[x2;x(i*k+1) x(i*k+2) x(i*k+3) x(i*k+4) x(i*k+5)];
end
end
end
ik=[eye(5) zeros(5,10)]; %输入信息码扩展
x3=x2*ik;
yout=[];
for i=1:n
g=[1 0 1 0 0 1 1 0 1 1 1];
[w,yo]=deconv(x3(i,:),g); %产生余式
yo=abs(rem(yo,2));
yout=[yout;yo];
end
yout=yout+x3; %产生信息码
end
运行结果:
msg =
1 1 0 1 0
0 1 1 0 1
0 1 0 0 0
1 1 1 0 1
0 0 1 0 0
code =
1 1 0 1 0 1 1 0 0 1 0 0 0 1 1
0 1 1 0 1 1 1 0 0 0 0 1 0 1 0
0 1 0 0 0 1 1 1 1 0 1 0 1 1 0
1 1 1 0 1 0 1 1 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1 1 1 0 1 0 1 1
code = GF(2) array.
Array elements =
1 1 0 1 0 1 0 1 0 1 0 0 0 1 1
0 1 1 1 1 1 1 0 0 0 0 1 0
1 0
0 0 0 0 0 1 1 1 1 0 0 0 1
1 0
1 1 0 0 1 0 1 1 1 0 1 0 0 0 1
0 0 1 1 0 0 1 1 1 1 0 1 0
1 1
decode = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)
Array elements =
1 1 0 1 0 1 1 0 0 1 0 0 0 1 1
0 1 1 0 1 1 1 0 0 0 0 1 0
1 0
0 1 0 0 0 1 1 1 1 0 1 0 1
1 0
1 1 1 0 1 0 1 1 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1 1 1 0 1 0
1 1。

相关主题