BCH码
不同于奇偶校验码只能检验数据传输是否出错,BCH码可以实现对数据的检验和纠错
BCH(n,k)中的n代表总码元,k代表有效码元,相应的n-k即代表纠错码元
本文着重比较分析BCH(255,207),BCH(255,131),BCH(255,87)的性能
仿真图
BCH(255,207)的码率为207/255=0.81,BCH(255,131)的码率为0.51,BCH(255,87)的码率为0.34,就传输效率来看,BCH(255,207)显著优于其他两者
但是就误码率分析,BCH(255,87)显著优于其他两者,当信噪比为7时,BCH(255,87)的误码率甚至接近于10^-4,这是因为BCH的纠错码元数为255-87=168,多于其余二者
MATLAB代码(版本为2024a)
clc;
clear all;
close all;
warning off;
SNR = [0:1:8];
count = 800;
N = 255;
K = [207,131,87];
for m = 1:length(K)
Bit_err=zeros(1,9);
for i = 1:length(SNR)
disp(['当前进度:',num2str((i+m*9-9)/27*100),'%'])
Num_err = 0;
Numbers = 0;
while Numbers <= count
message = randi([0,1],1,K(m));
msg = gf(message);
BCHcode_gf = bchenc(msg,N,K(m));
BCHcode_double=zeros(1,N);
for code_j=1:N
if BCHcode_gf(1,code_j)==1
BCHcode_double(1,code_j)=1;
end
end
BCH_receive = awgn(BCHcode_double,SNR(i),'measured');
receive_decoded = zeros(1,N);
for hard_j=1:N
if BCH_receive(hard_j)>0.5
receive_decoded(hard_j)=1;
end
end
receive_decoded=gf(receive_decoded);
BCHdecode = bchdec(receive_decoded,N,K(m));
BCHdecode_double = zeros(1,K(m));
for gf_to_double_j=1:K(m)
if BCHdecode(gf_to_double_j)==1
BCHdecode_double(gf_to_double_j)=1;
end
end
Err = biterr(BCHdecode_double,message);
Num_err = Num_err + Err;
Numbers = Numbers + 1;
end
Bit_err(i) = Num_err/(length(message)*Numbers);
end
if m==1
figure;
semilogy(SNR,Bit_err,'b-o');
xlabel('SNR');
ylabel('BER');
grid on;
elseif m==2
hold on
semilogy(SNR,Bit_err,'r-s');
elseif m==3
hold on
semilogy(SNR,Bit_err,'g-d');
legend('BCH(255,207)','BCH(255,131)','BCH(255,87)');
end
end