您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 2dpsk信号系统matlab实现
clearall;closeall;fs=4000000;%设定系统的抽样频率k=20000;%设定数字基带信号的频率fc=200000;%设定正弦载波频率t=0:1/fs:4000/fs;%仿真时间范围p=21;s=randint(1,p,2);%设定需要产生的码元个数m=s(ceil(k*t+0.01));%将基带生成时域信号figure(1)subplot(311)plot(t,m);axis([010e-4-0.21.2]);gridon;title('数字基带信号');b=randint(1,p,2);%将生成的基带转换为差分码fori=1:pif(i==1)if(s(i)==0)b(i)=0;elseb(i)=1;endelseif(s(i)==b(i-1))b(i)=0;elseb(i)=1;endendn=b(ceil(k*t+0.01));%将差分码生成时域信号subplot(312)plot(t,n);axis([010e-4-0.21.2]);gridon;title('差分码')x=(n-0.5).*2car=sin(2*pi*fc*t);%定义载波dpsk=x.*car;%2dpsk信号的载波调制subplot(313);plot(t,car);axis([010e-4-1.21.2]);title('正弦载波');figure(2)subplot(311);plot(t,dpsk);axis([010e-4-1.21.2]);title('2DPSK信号');gridon;vn=0.05;noise=vn.*(randn(size(t)));%产生噪音subplot(312);plot(t,noise);gridon;title('噪音信号');axis([010e-4-0.20.2]);dpskn=(dpsk+noise);%调制后加噪subplot(313);plot(t,dpskn);axis([010e-4-1.21.2]);title('加噪后信号');gridon;%带通滤波器fBW=40e3;f=[0:3e3:4e5];w=2*pi*f/fs;z=exp(w*j);BW=2*pi*fBW/fs;a=.8547;p=(j^2*a^2);gain=.135;Hz=gain*(z+1).*(z-1)./(z.^2-(p));Hz(Hz==0)=10^(8);a=[100.7305];b=[0.1350-0.135];dait=filter(b,a,dpskn);dait=dait.*10;figure(3)subplot(311);plot(t,dait);axis([010e-4-1.21.2]);title('通过带通滤波后输出');gridon;cm=dpsk.*car;%2dpsk相干解调subplot(312);plot(t,cm);axis([010e-4-1.21.2]);gridon;title('通过相乘器后输出');%低通滤波器p=0.72;gain1=0.14;Hz1=gain1*(z+1)./(z-(p));a1=[1-0.72];b1=[0.140.14];dit=filter(b1,a1,cm);dit=dit-mean(dit);subplot(313);plot(t,dit);axis([010e-4-1.21.2]);title('通过低通滤波器后输出');gridon;%抽样判决器H=1;L=0;Z=0;len=length(dit);forii=1:lenifdit(ii)=ZVs(ii)=H;elseVs(ii)=L;endendfigure(4)subplot(311)plot(t,Vs)title('解调后差分信号')axis([010e-4-0.21.2])gridon;c=randint(1,22,2);%产生解调后的差分码元forf=0:19c(f+1)=fix(Vs(f*200+50)+0.2)endd=randint(1,21,2);%定义差分译码后的码元forl=1:21%得到差分译码后的码元if(l==1)if(s(1)==0)d(1)=0;elsed(1)=1;endelseif(c(l)==c(l-1))d(l)=0;elsed(l)=1;endendy=d(ceil(k*t+0.01));subplot(313);plot(t,y);axis([010e-4-0.21.2]);title('码反变换输出');%基带信号与解调后的信号对比subplot(312)plot(t,m);axis([010e-4-0.21.2]);title('原始基带信号');
本文标题:2dpsk信号系统matlab实现
链接地址:https://www.777doc.com/doc-5964044 .html