matlab的dpsk,基于matlab的dpsk系统仿真代码

41528d3028836879cd698677c3999917.gif基于matlab的dpsk系统仿真代码

差分编码 function Y = difference(X) %UNTITLED Summary of this function goes here % Detailed explanation goes here a=length(X); Y=zeros(1,a); b=0.01:0.01:a; for(i=1:a)is((i-1)*100+1:i*100)=X(i); end figure plot(b,is); axis([0,a+1,-0.1,1.1]); title( 原始序列 ) grid if (X(1)==1)Y(1)=1; else Y(1)=0; endfor i=2:aif(X(i)-X(i-1)~=0) Y(i)=1;else Y(i)=0;end endY;t=0.01:0.01:a; for(i=1:a)st((i-1)*100+1:i*100)=Y(i); end figure plot(t,st); axis([0,a+1,-0.1,1.1]); title( 差分 编码 ) grid endPSK调制 function z=dpsk(X) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here fs=200;w=2; n=length(X); t=1:100; nn=1:100; n1=0.01:0.01:n;%os=zeros(1,100);for(i=1:n)is((i-1)*100+1:i*100)=X(i);st((i-1)*100+1:i*100)=0; endfor(nn=1:100)oss(nn)=sin(2*pi*w*(t(nn)/100));osc(nn)=sin(2*pi*w*(t(nn)/100)+pi); end %figure %subplot(2,1,1) %plot(t/100,oss); %axis([0,n+1,-1.1,1.1]); %title( 信号波形1 ) %grid %subplot(2,1,2) %plot(t/100,osc); %axis([0,n+1,-1.1,1.1]); %title( 信号波形2 ) %gridfor(i=1:n)if(X(i)==1)for(nn=1:100)st(100*(i-1)+nn)=oss(nn);endelse for(nn=1:100)st(100*(i-1)+nn)=osc(nn);endendend st; figure subplot(2,1,1) plot(n1,is); axis([0,n+1,-0.1,1.1]); title( 原始信号 ) grid subplot(2,1,2) plot(n1,st); axis([0,n+1,-1.1,1.1]); title( 调制信号 ) grid%%%%%%%%%%%%%功率谱 %f1=50; %figure %psd(spectrum.welch,st, fs ,f1),title( 调制信号功率谱密度 ); %gridtt=0.01:0.01:n; %%%%%%%%%%%%%%%%%%%%%高斯白噪声信道 stt=awgn(st,5); figure plot(tt,stt); axis([0,n+1,-1.5,1.5]); title( 通过 高斯信道后的信号 ); griddt=stt.*sin(2*pi*w*tt); figure subplot(2,1,1) plot(tt,dt); axis([0,n+1,-1.5,1.5]); title( 相乘后的波形 ); grid%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%低通滤波器[N,Wn]=buttord(2*pi*25,2*pi*50,3,25, s );%临界频率采用角频率表示? [b,a]=butter(N,Wn, s ); [bz,az]=impinvar(b,a,fs);%映射为数字的?? dt=filter(bz,az,dt); subplot(2,1,2)%15? plot(tt,dt); axis([0,n+1,-1.5,1.5]); title( 低通 滤波后的波形 ); grid %%%%%%%%%%%%%%%%%%%%%%%%%%抽样判决?dt2=0;for(i=1:n) for(j=1:100)% if(dt(100*(i-1)+j)>0)% dt1= dt1+1;% else dt1=dt1;dt1=dt1+dt(100*(i-1)+j);% end% dt2=dt1/100;enddt2=dt1/100;if(dt2>0.3)dtt(100*(i-1)+1:100*i)=1;dt2=0;dt1=0;else dtt(100*(i-1)+1:100*i)=0;dt2=0;dt1=0;endend figure %subplot(2,1,2) plot(tt,dtt); axis([0,n+1,-0.1,1.1]); title( 判决后的波形 ); grid %%%%%%%%%%%%逆码变换后的序列 z=zeros(1,n); for(i=1:n) if(dtt(100*(i-1)+50)==1)z(i)=1;else z(i)=0;end end z; end 解差分 function X =indifference (Y) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here a=length(Y); X=zeros(1,a); if(Y(1)==1)X(1)=1; else X(1)=0; end for(i=2:a) if(Y(i)==0)X(i)=X(i-1); else if(X(i-1)==0)X(i)=1;else X(i)=0;end end end X; t=0.01:0.01:a; for(i=1:a)st((i-1)*100+1:i*100)=X(i); end figure plot(t,st); axis([0,a+1,-0.1,1.1]); title( 解差分 ) grid end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值