您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 东南大学_短距离无线通信_信道编解码仿真实验报告
考虑BSC信道,令错误概率0.02:0.02:0.12p通过仿真分别确定无编码、码率1/3重复码以及(7,4)汉明码的BERclearallclcK=10000;N=3*K;G=[1101000;0110100;1110010;1010001;];H=[1001011;0101110;0010111;];%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%±àÂëx0=randi([0,1],K,1)';y0=repmat(x0,3,1);y0=reshape(y0,1,numel(y0));fori=1:K/4z0(7*i-6:7*i)=mod(x0(4*i-3:4*i)*G,2);end%%%%%%%%%%%%%%%%%%%%%%%%´«Êäc=rand(1,7*N/4);forii=1:6p=ii*0.02;x1=zeros(1,K);fori=1:Kifc(i)px1(i)=-x0(i)+1;elsex1(i)=x0(i);endendy1=zeros(1,N);fori=1:Nifc(i)py1(i)=-y0(i)+1;elsey1(i)=y0(i);endendz1=zeros(1,7*K/4);fori=1:7*K/4ifc(i)pz1(i)=-z0(i)+1;elsez1(i)=z0(i);endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ÒëÂëx2=x1;y2=zeros(1,K);fori=1:Kify1(3*i-2)+y1(3*i-1)+y1(3*i)2y2(i)=0;elsey2(i)=1;endendz2=zeros(1,7*K/4);mask=[0000000];fori=1:K/4zz=mod(z1(7*i-6:7*i)*H',2);zzz=zz(1)*4+zz(2)*2+zz(3)*1;switch(zzz)case4mask=[1000000];case2mask=[0100000];case1mask=[0010000];case6mask=[0001000];case3mask=[0000100];case7mask=[0000010];case5mask=[0000001];case0mask=[0000000];endz2(7*i-6:7*i)=double(bitxor(int8(mask),int8(z1(7*i-6:7*i))));endfori=1:K/4z3(4*i-3:4*i)=z2(7*i-3:7*i);endUncoded(ii)=length(find((x0-x2)==0))/K;Repitition(ii)=length(find((x0-y2)==0))/K;Hamming(ii)=length(find((x0-z3)==0))/K;endx=0.02:0.02:0.12;semilogx(x,Repitition,x,Hamming,x,Uncoded);xlabel('BER');legend('Repitition','Hamming','Uncoded');BSC信道中无编码性能最差(7,4)汉明码性能次之,复杂度最高1/3重复吗性能最优BER越高,三种编码的差距越明显考虑AWGN信道,设定单位信息比特能量Eb=1,信噪比Eb/变化范围为0:2:12dB,通过仿真分别确定无编码、码率1/3重复码以及(7,4)汉明码的BER(后两种采用硬译码算法)clearallclcK=10000;N=3*K;G=[1101000;0110100;1110010;1010001;];H=[1001011;0101110;0010111;];%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%±àÂëx0=randi([0,1],K,1)';y0=repmat(x0,3,1);y0=reshape(y0,1,numel(y0));fori=1:K/4z0(7*i-6:7*i)=mod(x0(4*i-3:4*i)*G,2);end%%%%%%%%%%%%%%%%%%%%%%%%´«Êäforii=1:7SNR=2*ii-2;Eb=1;SNR=10^(SNR/10);sigma=sqrt(Eb/SNR);AWGN=sigma*randn(1,N);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%a0=Eb*(-2*x0+1)+AWGN(1:K);b0=Eb*(-2*y0+1)/sqrt(3)+AWGN(1:N);c0=Eb*(-2*z0+1)*2/sqrt(7)+AWGN(1:7*K/4);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%a1=(sign(a0)-1)/(-2);b1=(sign(b0)-1)/(-2);c1=(sign(c0)-1)/(-2);a2=a1;b2=zeros(1,K);fori=1:Kifb1(3*i-2)+b1(3*i-1)+b1(3*i)2b2(i)=0;elseb2(i)=1;endendc2=zeros(1,7*K/4);mask=[0000000];fori=1:K/4cc=mod(c1(7*i-6:7*i)*H',2);ccc=cc(1)*4+cc(2)*2+cc(3)*1;switch(ccc)case4mask=[1000000];case2mask=[0100000];case1mask=[0010000];case6mask=[0001000];case3mask=[0000100];case7mask=[0000010];case5mask=[0000001];case0mask=[0000000];endc2(7*i-6:7*i)=double(bitxor(int8(mask),int8(c1(7*i-6:7*i))));endfori=1:K/4c3(4*i-3:4*i)=c2(7*i-3:7*i);endUncoded(ii)=length(find((x0-a2)==0))/K;Repitition(ii)=length(find((x0-b2)==0))/K;Hamming(ii)=length(find((x0-c3)==0))/K;endx=0:2:12;plot(x,Uncoded,x,Repitition,x,Hamming);xlabel('SNR');ylabel('BER');legend('Uncoded','Repitition','Hamming');AWGN信道中在SNR5dB无编码性能最优1/3重复码性能次之汉明码性能最差在SNR5dB无编码性能最优汉明码性能次之1/3重复码性能最差SNR越低,三种编码的差距越明显
本文标题:东南大学_短距离无线通信_信道编解码仿真实验报告
链接地址:https://www.777doc.com/doc-2793224 .html