完整word版通信仿真hamming码编码译码.docx

上传人:b****1 文档编号:10303040 上传时间:2023-05-24 格式:DOCX 页数:10 大小:69.01KB
下载 相关 举报
完整word版通信仿真hamming码编码译码.docx_第1页
第1页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第2页
第2页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第3页
第3页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第4页
第4页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第5页
第5页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第6页
第6页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第7页
第7页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第8页
第8页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第9页
第9页 / 共10页
完整word版通信仿真hamming码编码译码.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

完整word版通信仿真hamming码编码译码.docx

《完整word版通信仿真hamming码编码译码.docx》由会员分享,可在线阅读,更多相关《完整word版通信仿真hamming码编码译码.docx(10页珍藏版)》请在冰点文库上搜索。

完整word版通信仿真hamming码编码译码.docx

完整word版通信仿真hamming码编码译码

线性分组码

线性分组码的线性是指码组中码元间的约束关系为线性;分组是指编码时将每k个信息位一组进行独立处理,变换成长度为n(n>k)的二进制码组。

本次仿真采用(7,4)HAMMING码。

性能参数如下:

生成矩阵G:

1101000

0100100

1110010

1010001

校验矩阵H:

1001011

0101110

0010111

可纠错误图样:

伴随式

S=(S0,S1,S2)

陪集首

e=(e0e1e2e3e4e5e6)

000

0000000

100

1000000

010

0100000

001

0010000

110

0001000

011

0000100

111

0000010

101

0000001

码长:

n=7

信息位:

k=4

监督位:

n–k=3

最小距离:

d=3

码率:

k/n=4/7

(7,4)HAMMING码能纠正每一种单个随机错误。

MATLAB源程序

function[output_h74]=hamming74(input_h74)

%hamming74.m(7,4)HAMMING码编码器

%input_h74输入序列

%output_h74输出编码序列

if(rem(length(input_h74),4)~=0)

input_h74=[input_h74,zeros(1,4-rem(length(input_h74),4))];

end

n=length(input_h74)/4;

u=zeros(1,n*7);

j=1;

fori=1:

4:

n*4

u(j)=rem((input_h74(i)+input_h74(i+2)+input_h74(i+3)),2);

u(j+1)=rem((input_h74(i)+input_h74(i+1)+input_h74(i+2)),2);

u(j+2)=rem((input_h74(i+1)+input_h74(i+2)+input_h74(i+3)),2);

u(j+3)=input_h74(i);

u(j+4)=input_h74(i+1);

u(j+5)=input_h74(i+2);

u(j+6)=input_h74(i+3);

j=j+7;

end

output_h74=u;

%hamming74.m(7,4)HAMMING码编码器

function[h4_output,h7_output]=h47(h74_channel_output)

%h47.m(7,4)HAMMING码译码器

%h74_channel_output信道输入序列

%h4_output译码输出序列

%h7_output纠错后的信道输入序列

if(rem(length(h74_channel_output),7)~=0)

h74_channel_output=[h74_channel_output,zeros(1,7-rem(length(h74_channel_output),7))];

end

n=length(h74_channel_output)/7;

u4=zeros(1,n*4);

u7=zeros(1,n*7);

s=zeros(1,7-4);

e=zeros(1,7);

j=1;

fori=1:

7:

n*7

s(i)=rem((h74_channel_output(i)+h74_channel_output(i+3)+h74_channel_output(i+5)+h74_channel_output(i+6)),2);

s(i+1)=rem((h74_channel_output(i+1)+h74_channel_output(i+3)+h74_channel_output(i+4)+h74_channel_output(i+5)),2);

s(i+2)=rem((h74_channel_output(i+2)+h74_channel_output(i+4)+h74_channel_output(i+5)+h74_channel_output(i+6)),2);

e(i)=s(i)*(1-s(i+1))*(1-s(i+2));

e(i+1)=(1-s(i))*s(i+1)*(1-s(i+2));

e(i+2)=(1-s(i))*(1-s(i+1))*s(i+2);

e(i+3)=s(i)*s(i+1)*(1-s(i+2));

e(i+4)=(1-s(i))*s(i+1)*s(i+2);

e(i+5)=s(i)*s(i+1)*s(i+2);

e(i+6)=s(i)*(1-s(i+1))*s(i+2);

fork7=0:

6

u7(i+k7)=rem(h74_channel_output(i+k7)+e(i+k7),2);

end

fork4=0:

3

u4(j+k4)=u7(i+7-4+k4);

end

j=j+4;

end

h4_output=u4;

h7_output=u7;

%h47.m(7,4)HAMMING码译码器

function[p]=smldPe55_74(snr_in_dB)

%smldPe55_74.m二进制双极性(7,4)HAMMING码通信系统的蒙特卡罗仿真函数

%snr_in_dB信噪比

%p误码率

E=1;

SNR=exp(snr_in_dB*log(10)/10);%Eb/N0

sgma=E/sqrt(2*SNR);

N=16;

loop=10^5/N;

Ns=N*loop;%仿真序列长度10^5,运行时间约1.5分钟

numoferr_74=0;

temp=0;

dsource=zeros(1,N);

output_h74=hamming74(dsource);

channel_output=zeros(1,length(output_h74));

[h4output,h7output]=h47(output_h74);

forj=1:

loop

fori=1:

N

temp=rand;

if(temp<0.5)

dsource(i)=0;

else

dsource(i)=1;

end

end

output_h74=hamming74(dsource);

fori=1:

length(output_h74)

if(output_h74(i)==0)

r=-E+gngauss(sgma);

else

r=E+gngauss(sgma);

end

if(r<0)

channel_output(i)=0;

else

channel_output(i)=1;

end

end

[h4output,h7output]=h47(channel_output);

fori=1:

N%length(h4output)

if(h4output(i)~=dsource(i))

numoferr_74=numoferr_74+1;

end

end

end

numoferr_74,

p=numoferr_74/Ns;

%二进制双极性(7,4)HAMMING码通信系统的蒙特卡罗仿真函数

function[p_err,gamma_db]=p_e_hd_a(gamma_db_l,gamma_db_h,k,n,d_min)

%p_e_hd_a.m硬判决性能估计函数

%p_err误码率

%gamma_db信噪比范围

%gamma_db_l>10信噪比下界

%gamma_db_h信噪比上界

%k信息码长

%n编码长度

%d_min最小距离

gamma_db=[gamma_db_l:

(gamma_db_h-gamma_db_l)/20:

gamma_db_h];

gamma_b=10.^(gamma_db/10);

R_c=k/n;

p_b=q(sqrt(2.*R_c.*gamma_b));

p_err=(2^k-1).*(4*p_b.*(1-p_b)).^(d_min/2);

%p_e_hd_a.m硬判决性能估计函数

function[p_err,gamma_db]=p_e_sd_a(gamma_db_l,gamma_db_h,k,n,d_min)

%p_e_sd_a.m软判决性能估计函数

%p_err误码率

%gamma_db信噪比范围

%gamma_db_l>10信噪比下界

%gamma_db_h信噪比上界

%k信息码长

%n编码长度

%d_min最小距离

gamma_db=[gamma_db_l:

(gamma_db_h-gamma_db_l)/20:

gamma_db_h];

gamma_b=10.^(gamma_db/10);

R_c=k/n;

p_err=(2^k-1).*q(sqrt(d_min.*R_c.*gamma_b));

%p_e_sd_a.m软判决性能估计函数

%ce55_74.m仿真绘图语句

%仿真序列长度10^5,运行时间约20分钟

echoon

SNRindB55741=0:

16;

SNRindB55742=0:

0.1:

16;

smld_err_prb55=zeros(1,length(SNRindB55741));

smld_err_prb74=zeros(1,length(SNRindB55741));

SNR5574=0;

theo_err_prb5574=zeros(1,length(SNRindB55742));%

fori=1:

length(SNRindB55741)

smld_err_prb55(i)=smldPe55(SNRindB55741(i));

smld_err_prb74(i)=smldPe55_74(SNRindB55741(i));

end

fori=1:

length(SNRindB55742)

SNR5574=exp(SNRindB55742(i)*log(10)/10);

theo_err_prb5574(i)=(1/2)*erfc(sqrt(2*SNR5574)/sqrt

(2));

%Qfuncty=(1/2)*erfc(x/sqrt

(2));

%theo_err_prb(i)=Qfunct(sqrt(2*SNR));

end

[p_err_ha,gamma_db_ha]=p_e_hd_a(5,16,4,7,3);

%p_e_hd_a.m硬判决性能估计函数

[p_err_sa,gamma_db_sa]=p_e_sd_a(5,16,4,7,3);

%p_e_sd_a.m软判决性能估计函数

%绘图语句

figure;

semilogy(SNRindB55741,smld_err_prb55,'b*-');

holdon

axis([0,16,1e-5,1]);

xlabel('Eb/N0indB');

ylabel('Pe');

title('(7,4)HAMMING编码系统仿真结果与未编码系统的比较,以及软硬判决解码误码率界');

semilogy(SNRindB55741,smld_err_prb74,'ro-');

semilogy(SNRindB55742,theo_err_prb5574,'b:

');

semilogy(gamma_db_ha,p_err_ha,'g');

semilogy(gamma_db_sa,p_err_sa,'m');

%ce55_74.m仿真绘图语句

运行结果

下图(ce55_74的运行结果)给出了不同信噪比条件下,发送100000比特的二进制双极性(7,4)HAMMING编码通信系统的蒙特卡罗仿真结果,以及未编码系统的仿真结果和未编码系统的理论值曲线,还给出了软硬判决解码的误码率估计函数。

但在绘图时发现,绘出的这两个函数曲线居然在未编码的理论值曲线之上。

这不仅是因为仿真信噪比范围不同(蒙特卡罗仿真0:

16;估计函数有效范围在16dB以上),还因为,在大于10dB以上的信噪比下,理论误码率低于10的-5次方,由于仿真的时间复杂度限制,无法得出误码率低于10的-5次方的蒙特卡罗仿真结果。

从仿真角度讲,图中绘出这两个软硬判决解码的误码率估计函数曲线已失去了意义,仅做参考。

从下图的仿真结果可见,(7,4)HAMMING编码可以降低二进制双极性通信系统的误码率,从而提高通信的有效性。

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2