通信原理Matlab仿真实验报告

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

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

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

资源描述

通信原理Matlab仿真实验报告学号:姓名:实验一1、利用Matlab实现矩形信号串信号分解与合成⑴Matlab程序代码:①矩形信号串信号分解与合成函数rectexpd():functionrectexpd(T1,T0,m)%矩形信号串信号分解与合成%T1:矩信号区间为(-T1/2,T1/2)%T0:矩形矩信信号串周期%m:傅里叶级数展开项次数t1=-T1/2:0.01:T1/2;t2=T1/2:0.01:(T0-T1/2);t=[(t1-T0)';(t2-T0)';t1';t2';(t1+T0)'];n1=length(t1);n2=length(t2);%根据周期矩形信号函数周期,计算点数f=[ones(n1,1);zeros(n2,1);ones(n1,1);zeros(n2,1);ones(n1,1)];%构造周期矩形信号串y=zeros(m+1,length(t));y(m+1,:)=f';figure(1);plot(t,y(m+1,:));%绘制周期矩形信号串axis([-(T0+T1/2)-0.5,(T0+T1/2)+0.5,0,1.2]);set(gca,'XTick',[-T0,-T1/2,T1/2,T0]);set(gca,'XTickLabel',{'-T0','-T1/2','T1/2','T0'});title('矩形信号串');gridon;a=T1/T0;pause;%绘制离散幅度谱freq=[-20:1:20];mag=abs(a*sinc(a*freq));stem(freq,mag);x=a*ones(size(t));fork=1:m%循环显示谐波叠加图形pause;x=x+2*a*sinc(a*k)*cos(2*pi*t*k/T0);y(k,:)=x;plot(t,y(m+1,:));holdon;plot(t,y(k,:));holdoff;gridon;axis([-(T0+T1/2)-0.5,[T0+T1/2]+0.5,-0.5,1.5]);title(strcat(num2str(k),'次谐波叠加'));xlabel('t');endpause;plot(t,y(1:m+1,:));gridon;axis([-T0/2,T0/2,-0.5,1.5]);title('各次谐波叠加');xlabel('t');②在命令窗口调用rectexpd()函数:T1=5;T0=10;m=5;rectexpd(T1,T0,m)⑵Matlab仿真结果:-T0-T1/2T1/2T000.20.40.60.81矩形信号串-20-15-10-50510152000.050.10.150.20.250.30.350.40.450.5-10-50510-0.500.511.51次谐波叠加t-10-50510-0.500.511.53次谐波叠加t-10-50510-0.500.511.55次谐波叠加t-10-50510-0.500.511.52次谐波叠加t-10-50510-0.500.511.54次谐波叠加t-5-4-3-2-1012345-0.500.511.5各次谐波叠加t2、利用Matlab实现连续信号卷积运算⑴Matlab程序代码:①连续信号卷积运算的通用函数sconv():function[f,k]=sconv(f1,f2,k1,k2,p)f=conv(f1,f2);f=f*p;k0=k1(1)+k2(1);k3=length(f1)+length(f2)-2;k=k0:p:k3*p;subplot(2,2,1);plot(k1,f1);title('f1(t)');xlabel('t');ylabel('f1(t)');subplot(2,2,2);plot(k2,f2);title('f2(t)');xlabel('t');ylabel('f2(t)');subplot(2,2,3);plot(k,f);title('f(t)=f1(t)*f2(t)');xlabel('t');ylabel('f(t)');h=get(gca,'position');h(3)=2.5*h(3);set(gca,'position',h);②在命令窗口调用sconv()函数:p=0.01;k1=0:p:2;f1=exp(-k1);k2=0:p:3;f2=ones(1,length(k2));[f,k]=sconv(f1,f2,k1,k2,p)⑵Matlab仿真结果:00.511.5200.51f1(t)tf1(t)012300.511.52f2(t)tf2(t)00.511.522.533.544.5500.51f(t)=f1(t)*f2(t)tf(t)实验二1、用Matlab模拟图形A律解码⑴Matlab程序代码:①建立函数ADecode()functiony=ADecode(code,n)codesize=size(code);cr_len=codesize(1);cl_len=codesize(2);ca=zeros(1,cl_len-1);fori=1:cr_lenca=code(i,2:n);s=0;forj=1:n-1s=s+ca(j)*2^(n-1-j);enda=code(i,1);y(i)=s*((-1)^(a+1));endy=y/(2^(n-1));A=87.6;A1=1+log(A);forj=1:length(y)if(y(j)=0)if(y(i)=1/A1)y(j)=y(j)*A1/A;elsey(j)=exp(y(j)*A1-1/A);endelsetemp=-y(j);if(temp=1/A1)y(j)=-temp*A1/A;elsey(j)=-exp(temp*A1-1)/A;endendend②建立函数APCM()functioncode=APCM(x,n)xmax=max(abs(x));x=x/xmax;xlen=length(x);y=zeros(1,xlen);A=87.6;A1=1+log(A);fori=1:xlenifx(i)=0ifx(i)=1/Ay(i)=(A*x(i))/A1;elsey(i)=(1+log(A*x(i)))/A1;endelsex1=-x(i);ifx1=1/Ay(i)=-(A*x1)/A1;elsey(i)=-(1+log(A*x1))/A1;endendendy1=y*(2^(n-1)-1);y1=round(y1);code=zeros(length(y1),n);c2=zeros(1,n-1);fori=1:length(y1)if(y1(i)0)c1=1;elsec1=0;y1(i)=-y1(i);endforj=1:n-1r=rem(y1(i),2);y1(i)=(y1(i)-r)/2;c2(j)=r;endc2=fliplr(c2);code(i,:)=[c1c2];end③在新函数中调用前两个函数t=0:0.01:1;x=sin(2*pi*t);code=APCM(x,7);y=ADecode(code,7);subplot(2,1,1)plot(t,x);title('原函数的图形');subplot(2,1,2)plot(t,y);title('解码后函数的图形');⑵Matlab仿真结果:00.10.20.30.40.50.60.70.80.91-1-0.500.51原函数的图形00.10.20.30.40.50.60.70.80.91-1-0.500.5解码后函数的图形2、用Matlab模拟DSB调制及解调过程⑴Matlab程序代码:closeall;clearall;dt=0.001;%采样时间间隔fm=1;%信源最高频率fc=10;%载波中心频率N=4096;T=N*dt;t=0:dt:T-dt;mt=sqrt(2)*cos(2*pi*fm*t);%信源s_dsb=mt.*cos(2*pi*fc*t);%DSB-SC双边带抑制载波调幅B=2*fm;figure(1);subplot(311)plot(t,s_dsb,'b-');holdon;%画出DSB信号波形plot(t,mt,'r--');%画出m(t)信号波形title('DSB调制信号');xlabel('t');gridon;%DSBdemodulationrt=s_dsb.*cos(2*pi*fc*t);rt=rt-mean(rt);[f,rf]=T2F(t,rt);[t,rt]=lpf(f,rf,B);subplot(312)plot(t,rt,'k-');holdon;plot(t,mt/2,'r--');title('相干解调后的信号波形与输入信号的比较');xlabel('t');gridon;subplot(313)[f,sf]=T2F(t,s_dsb);%求调制信号的频谱psf=(abs(sf).^2)/T;%求调制信号的功率谱密度plot(f,psf);axis([-2*fc2*fc0max(psf)]);title('DSB信号功率谱');xlabel('f');gridon;⑵Matlab仿真结果:00.511.522.533.544.5-202DSB调制信号t00.511.522.533.544.5-101相干解调后的信号波形与输入信号的比较t-20-15-10-50510152000.5DSB信号功率谱f实验三1、用Matlab模拟双极性归零码⑴Matlab程序代码:functiony=drz(x)t0=300;x=[100110000101];t=0:1/t0:length(x);fori=1:length(x);if(x(i)==1)forj=1:t0/2y(t0/2*(2*i-2)+j)=1;y(t0/2*(2*i-1)+j)=0;endelseforj=1:t0/2y(t0/2*(2*i-2)+j)=-1;y(t0/2*(2*i-1)+j)=0;endendendy=[y,x(i)];M=max(y);m=min(y);subplot(211)plot(t,y);gridon;axis([0,i,m-0.1,M+0.1]);title('100110000101');⑵Matlab仿真结果:2、用Matlab产生2FSK信号⑴Matlab程序代码:①建立函数fskdigital()functionfskdigital(s,f1,f2)t=0:2*pi/99:2*pi;m1=[];c1=[];b1=[];forn=1:length(s)ifs(n)==0;m=ones(1,100);c=sin(f2*t);b=zeros(1,100)elses(n)==1;m=ones(1,100);c=sin(f1*t);b=ones(1,100)endm1=[m1m];c1=[c1c];b1=[b1b];endfsk=c1.*m1;subplot(211);plot(b1,'r')title('原始信号');axis([0100*length(s)-0.11.1]);gridon;subplot(212);plot(fsk)title('2FSK信号');gridon;②在命令窗口调用函数fskdigital()s=[10110010];f1=200;f2=100;fskdigital(s,f1,f2)⑵Matlab仿真结果:010020030040050060070080000.20.40.60.81原始信号0100200300400500600700800-1-0.500.512FSK信号3、用Matlab的simulink模块模拟三角波的分解与还原⑴模块图⑵仿真结果:①三角波原图②用矩形波近似的冲击函数③分解后的三角波④经低通还原的三角波

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

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

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

×
保存成功