当前位置:文档之家› 通信原理课程设计报告资料

通信原理课程设计报告资料

通信工程与系统课程设计报告题目:搭建简单分组传输的(帧传输)的基带数字通信系统姓名学号专业班级指导教师2015年10 月10 日三、课程设计解决的主要问题:(1)尽可能的获得较小的误码率(2)选用何种信道码何种线路码(3)如何进行信道编码(4)如何进行线路编码(5)如何进行抽样和判决(6)如何进行线路编码译码四、设计内容1、整体设计方案(1)产生随机矩阵信号(2)对随机信号分帧对随机信号进行信道编码,采用汉明7-4码(3)对信号进行线路编码,采用双极性归零的差分曼彻斯特编码(4)在信道内填加高斯白噪声(5)对信号进行抽样判决(6)对信号进行抽样计算误码率输出检验前后的误码率对比五、结果与分析六、总结与心得:七、附件:源程序及注解1、子程序汉明码编码function y=enhanming(a,N) %a为编码序列,N为帧数%生成矩阵G=[1 0 0 0 1 1 1;0 1 0 0 1 1 0;0 0 1 0 1 0 1;0 0 0 1 0 1 1]; for k=1:Ncode=[a(4*k-3) a(4*k-2) a(4*k-1) a(4*k)]*G;for l=0:6y(7*k-l)=mod(code(7-l),2); %y为汉明码endend汉明码译码function y=dehanming(C,N,K)A=zeros(7*N,1);%编码后信号S=zeros(N,3); %校验子E=zeros(7*N,1);%错误图样I=zeros(7*N,1);%解调纠错后的矩阵NEW=zeros(K,1);%收到的信号%监督矩阵H=[1 1 1 0 1 0 0;1 1 0 1 0 1 0;1 0 1 1 0 0 1] ;for n=1:NM=7*n-6;Z=4*n-3;T=7*n-3;V=4*n;L=7*n;%s=C(M:L,1)'*H';s=C(1,M:L)*H';S(n,:)=mod(s,2);if S(n,:)==[0 0 0]E(M:L,1)=[0 0 0 0 0 0 0]';elseif S(n,:)==[0 0 1] E(M:L,1)=[0 0 0 0 0 0 1]';elseif S(n,:)==[0 1 0] E(M:L,1)=[0 0 0 0 0 1 0]';elseif S(n,:)==[0 1 1] E(M:L,1)=[0 0 0 0 1 0 0]';elseif S(n,:)==[1 0 0] E(M:L,1)=[0 0 0 1 0 0 0]';elseif S(n,:)==[1 0 1] E(M:L,1)=[0 0 1 0 0 0 0]';elseif S(n,:)==[1 1 0] E(M:L,1)=[0 1 0 0 0 0 0]';elseif S(n,:)==[1 1 1] E(M:L,1)=[1 0 0 0 0 0 0]';End曼彻斯特编码function y=dehanming(C,N,K)A=zeros(7*N,1);%编码后信号S=zeros(N,3); %校验子E=zeros(7*N,1);%错误图样I=zeros(7*N,1);%解调纠错后的矩阵NEW=zeros(K,1);%收到的信号%监督矩阵H=[1 1 1 0 1 0 0;1 1 0 1 0 1 0;1 0 1 1 0 0 1] ;for n=1:NM=7*n-6;Z=4*n-3;T=7*n-3;V=4*n;L=7*n;%s=C(M:L,1)'*H';s=C(1,M:L)*H';S(n,:)=mod(s,2);if S(n,:)==[0 0 0]E(M:L,1)=[0 0 0 0 0 0 0]';elseif S(n,:)==[0 0 1] E(M:L,1)=[0 0 0 0 0 0 1]'; elseif S(n,:)==[0 1 0] E(M:L,1)=[0 0 0 0 0 1 0]'; elseif S(n,:)==[0 1 1] E(M:L,1)=[0 0 0 0 1 0 0]'; elseif S(n,:)==[1 0 0] E(M:L,1)=[0 0 0 1 0 0 0]'; elseif S(n,:)==[1 0 1] E(M:L,1)=[0 0 1 0 0 0 0]'; elseif S(n,:)==[1 1 0] E(M:L,1)=[0 1 0 0 0 0 0]'; elseif S(n,:)==[1 1 1] E(M:L,1)=[1 0 0 0 0 0 0]'; end曼彻斯特译码function y=endiffmanchester(x)% diffmanchester ecoderlastcode=1; %设定初始值为1for i= 1:length(x)if (x(i)==1) %1跳变0不跳变if (lastcode==1)y(2*i-1)=-1;y(2*i)=1;lastcode=1;elsey(2*i-1)=1;y(2*i)=-1;lastcode=-1;endelseif (lastcode==1)y(2*i-1)=1;y(2*i)=-1;lastcode=-1;elsey(2*i-1)=-1;y(2*i)=1;lastcode=1;endendEnd抽样function y=chouyang(x,n)for i=1:n%av(i)=(x(6*i-5)+x(6*i-4)+x(6*i-3)+x(6*i-2)+x(6*i-1)+x(6*i))/6; %抽样av(i)=(x(4*i-3)+x(4*i-2)+x(4*i-1)+x(4*i))/4;if(av(i)>0)y(i)=1;elsey(i)=0;endendy;end2、总程序%% 产生随机信号N=1024; %512bit随机码a=randint(1,N,2);figure(1)subplot(311)stairs(a)axis([0 60 0 1.5])xlabel('码元')title('随机码')%%分帧for i=0:255msg1(i+1,(1:4))=a(1,(1+i*4:4+i*4)); i=i+1;endfor SNR=-5:1:5 %%信噪比t=SNR+6%%分帧传输for i=0:63 %%16bit一帧 msg=msg1((4*i+1):(4*i+4),1:4);%%汉明编码msgnew=enhanming(msg,4);subplot(312)stairs(msgnew)axis([1 28 0 1.5]);xlabel('码元');title('汉明编码');%%线路码——曼彻斯特p=length(msgnew);xn=msgnew(1,1:p);xl(1,1:2*p)=endiffmanchester(xn);subplot(313)stairs(xl)axis([1 56 -1.5 1.5]);xlabel('码元');title('曼彻斯特编码');%%一个码元4次采样值nn=length(xl);whole=caiyang(xl);%%加噪声zao=awgn(whole,SNR);figure(2)subplot(411)plot(zao)title('加高斯白噪声');axis([1 224 -1.5 1.5]);%%抽样判决wholenew=chouyang(zao,nn);nn1=length(a1);subplot(412)stairs(wholenew)title('抽样判决后编码');axis([1 56 -1.5 1.5]);%%曼彻斯特译码decode=dediffmanchester(wholenew);subplot(413)stairs(decode)title('曼彻斯特译码');axis([1 28 -1.5 1.5]);subplot(414)stairs(a)axis([1 28 -1.5 1.5]);xlabel('码元');title('随机码');%%汉明码译码纠错jiucuo=dehanming(decode,4,16);jiucuonew=reshape(jiucuo,4,4);finall((1+i*4):(4+4*i),1:4)=jiucuonew;end%%计算误码率final=zeros(1,1024);s=1;for i=1:256;for j=1:4;final(1,s)=finall(i,j); s=s+1;endendfinal;a1=endiffmanchester(a);a2=caiyang(a1);a3=awgn(a2,SNR);a4=chouyang(a3,nn1);a5=dediffmanchester(a4);zhong=mod(final+a,2);cuochu=find(zhong==1);geshu=length(cuochu);ber(1,t)=geshu/1024;zhong1=mod(a5+a,2);cuochu1=find(zhong1==1);geshu1=length(cuochu1);ber1(1,t)=(geshu1)/1024;endfigure(3)plot(-5:1:5,ber,'b-*')title('误比特率');xlabel('信噪比');ylabel('误比特率');set(gca,'xtick',-5:1:5);axis([-5 5 0 0.3])hold onplot(-5:1:5,ber1,'r-*')set(gca,'xtick',-5:1:5);axis([-5 5 0 0.3])八、指导老师评语及得分:。

相关主题