通信原理仿真实验

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

通信原理仿真实验实验一各种信道码性能比较[实验要求]1.单极性(不)归零码的波形及其功率谱2.双极性(不)归零码的波形及其功率谱[程序设计]globaldttdfNcloseallN=2^15;L=32;M=N/L;Rb=2;Ts=1/Rb;dt=Ts/L;df=1/(N*dt);T=N*dt;Bs=N*df/2;Na=4;f=[-Bs+df/2:df:Bs];t=[-T/2+dt/2:dt:T/2];SumPRZ=zeros(size(f));SumPNRZ=zeros(size(f));SumPdRZ=zeros(size(f));SumPdNRZ=zeros(size(f));Again=100;forii=1:Againa=round(rand(1,M));b=sign(randn(1,M));sNRZ=zeros(1,N);sRZ=zeros(1,N);sdNRZ=zeros(1,N);sdRZ=zeros(1,N);forjj=1:L分栏显示sNRZ(jj+[0:M-1]*L)=a;endforkk=1:0.5*Ts/dt;sRZ(kk+[0:M-1]*L)=a;endforjj=1:LsdNRZ(jj+[0:M-1]*L)=b;endforkk=1:0.5*Ts/dt;sdRZ(kk+[0:M-1]*L)=b;endXRZ=t2f(reshape(sRZ,1,N));XNRZ=t2f(reshape(sNRZ,1,N));XdRZ=t2f(reshape(sdRZ,1,N));XdNRZ=t2f(reshape(sdNRZ,1,N));SumPRZ=SumPRZ+(XRZ.*conj(XRZ))/T;SumPNRZ=SumPNRZ+(XNRZ.*conj(XNRZ))/T;SumPdRZ=SumPdRZ+(XdRZ.*conj(XdRZ))/T;SumPdNRZ=SumPdNRZ+(XdNRZ.*conj(XdNRZ))/T;endPRZ=SumPRZ/Again;PNRZ=SumPNRZ/Again;PdRZ=SumPdRZ/Again;PdNRZ=SumPdNRZ/Again;figure(1)PRZ=30+10*log10(PRZ+eps);PNRZ=30+10*log10(PNRZ+eps);PdRZ=30+10*log10(PdRZ+eps);PdNRZ=30+10*log10(PdNRZ+eps);subplot(2,2,1);plot(f/Rb,PRZ,'g');axis([-8,+8,-20,50]);title('单极性归零码功率谱','fontsize',20);xlabel('f/Rb','fontsize',20);ylabel('P(mdB)','fontsize',20);subplot(2,2,2);plot(f/Rb,PNRZ);axis([-8,+8,-20,50]);title('单极性不归零码功率谱','fontsize',20);xlabel('f/Rb','fontsize',20);ylabel('P(mdB)','fontsize',20);subplot(2,2,3);plot(f/Rb,PdRZ,'g');axis([-8,+8,-20,50]);title('双极性归零码功率谱','fontsize',20);xlabel('f/Rb','fontsize',20);ylabel('P(mdB)','fontsize',20);subplot(2,2,4);plot(f/Rb,PdNRZ);axis([-8,+8,-20,50]);title('双极性不归零码功率谱','fontsize',20);xlabel('f/Rb','fontsize',20);ylabel('P(mdB)','fontsize',20);figure(2)codet=dt*L;subplot(2,2,1)plot(t/codet,reshape(sRZ,1,N),'g','LineWidth',3)title('单极性归零码码型','fontsize',20);axis([-8,8,-0.2,1.2])xlabel('t/Ts','fontsize',20)gridonsubplot(2,2,2)plot(t/codet,reshape(sNRZ,1,N),'g','LineWidth',3)title('单极性不归零码码型','fontsize',20);axis([-8,8,-0.2,1.2])xlabel('t/Ts','fontsize',20)gridonsubplot(2,2,3)plot(t/codet,reshape(sdRZ,1,N),'g','LineWidth',3)title('双极性归零码码型','fontsize',20);axis([-8,8,-1.2,1.2])xlabel('t/Ts','fontsize',20)gridonsubplot(2,2,4)plot(t/codet,reshape(sdNRZ,1,N),'g','LineWidth',3)title('双极性不归零码码型','fontsize',20);axis([-8,8,-1.2,1.2])xlabel('t/Ts','fontsize',20)gridon[实验结果][实验结论]通过实验结果可以明显看到,单极性码的功率谱具有双极性码所不具有的离散分量,而归零码的带宽是不归零码的带宽的两倍(归零码占空比为0.5)实验二:升余弦滚降系统设计[实验要求]当滚降系数05.,发送码元幅值为0、2时,作出升余弦滚降波形的眼图及功率谱[程序设计]globaldttdfNcloseallN=2^13;L=32;M=N/LRb=2;Ts=1/Rb;dt=Ts/L;df=1/(N*dt)T=N*dtBs=N*df/2Na=4;alpha=0.5t=[-T/2+dt/2:dt:T/2];f=[-Bs+df/2:df:Bs];g1=sin(pi*t/Ts)./(pi*t/Ts);g2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);g=g1.*g2;G=t2f(g);figure(1)set(1,'Position',[10,50,300,200])figure(2)set(2,'Position',[400,50,300,200])holdongridxlabel('tinus')ylabel('s(t)inV')EP=zeros(size(f))+eps;forii=1:100a=sign(randn(1,M))+1;imp=zeros(1,N);imp(L/2:L:N)=a/dt;S=t2f(imp).*G;s=f2t(t2f(imp).*G);s=real(s);P=S.*conj(S)/T;EP=(EP*(ii-1)+P+eps)/ii;figure(1)plot(f,30+10*log10(EP),'g');gridaxis([-3,+3,-50,50])xlabel('f(MHz)')ylabel('Ps(f)(dBm/MHz)')figure(2)tt=[0:dt:Na*L*dt];forjj=1:Na*L:N-Na*Lplot(tt,s(jj:jj+Na*L));endend[实验结果]实验三:取样偏差与误码率[实验要求]试作出最佳基带系统的PeENb~0曲线,并与理论误码作一比较。升余弦滚降系数05.,取样时间的偏差是Ts4。[程序设计]globaldttfdfNTcloseallclearEb_N0PeN=2^13;L=8;M=N/LRb=2;Ts=1/Rb;dt=Ts/L;df=1/(N*dt)T=N*dtBs=N*df/2alpha=0.5t=linspace(-T/2,T/2,N);f=linspace(-Bs,Bs,N)+eps;figure(1)set(1,'Position',[10,50,300,200])hr1=sin(pi*t/Ts)./(pi*t/Ts);hr2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);hr=hr1.*hr2;HR=abs(t2f(hr));GT=sqrt(HR);GR=GT;forloop1=1:20Eb_N0(loop1)=(loop1-1)eb_n0(loop1)=10^(Eb_N0(loop1)/10);Eb=1;n0=Eb/eb_n0(loop1);sita=n0*Bs;n_err=0;forloop2=1:5a=sign(randn(1,M));imp=zeros(1,N);imp(L/2:L:N)=a/dt;IMP=t2f(imp);n_ch=sqrt(sita)*randn(size(t));nr=real(f2t(t2f(n_ch).*GR));sr=real(f2t(IMP.*HR))+nr;y=sr(3*L/4:L:N);aa=sign(y);n_err=n_err+length(find(aa~=a))endPe(loop1)=n_err/(M*loop2)figure(1)semilogy(Eb_N0,Pe)holdonsemilogy(Eb_N0,0.5*erfc(sqrt(10.^(Eb_N0/10))),'g')axis([0,9,1e-4,1])legend('理论误码率曲线','判决定时误差Ts/4时的实际误码率曲线')xlabel('Eb/N0单位:dB','fontsize',20);ylabel('Pe','fontsize',20);title('误码率曲线','fontsize',20)endend[实验结果][实验结论]抽样时间偏差会增加误码率,而且,我们明显看到,信噪比越大,抽样偏差的误码影响越大,可见,在高信噪比是,要求定时相当严格,否则会大大降低系统性能。实验四:多径传输[实验要求]信道是多径信道,Ts2,a=0.5,fjaefC21)(,升余弦滚降系数为05.,取样时间无偏差,试作出基带传输系统的误码率曲线,即PeENb~0[程序设计]globaldttfdfNcloseallN=2^13;L=16;M=N/LRb=2;Ts=1/Rb;dt=Ts/L;df=1/(N*dt)T=N*dtBs=N*df/2;Na=6;alpha=0.5;Again=20;t=linspace(-T/2,T/2,N);f=linspace(-Bs,Bs,N)+eps;g1=sin(pi*t/Ts)./(pi*t/Ts);g2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);g=g1.*g2;G=t2f(g);tao=Ts/2;C=1-0.5*exp(-j*(2*pi*f*tao));EbVSNo=0:10;Eb=1;MultiSumErrorCode=zeros(size(EbVSNo));SumErrorCode=zeros(size(EbVSNo));forii=EbVSNoNo=Eb/(10^(ii/10));PNoise=No*Bs;forjj=1:Againa=sign(randn(1,M));imp=zeros(1,N);imp(L/2:L:N)=a/dt;noise=sqrt(PNoise)*randn(1,N);NOISE=t2f(noise);noiseOut=real(f2t(NOISE.*sqrt(abs(G))));IMP=t2f(imp);y=real(f2t(IMP.*abs(G).*C))+noiseOut;yy=real(f2t(IMP.*abs(G)))+noiseOut;yDecided=sign(y(L/2:L:N));yyDecided=sign(yy(L/2:L:N));MultiSumErrorCode(ii+1)

1 / 8
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功