您好,欢迎来到爱go旅游网。
搜索
您的当前位置:首页通信原理频带传输之BDPSK差分检测

通信原理频带传输之BDPSK差分检测

来源:爱go旅游网
通信原理频带传输之BDPSK差分检测

代码:

%%%%%%%%%%%%%%%%%%%%%%%%%%%2DPSK信号差分检测代码%%%%%%%%%%%%%%%%%%%%%% str='Helloworld';%待传码元字符串 close all;

dec_8=dec2bin(str,8);%转换为8位形式 b=dec_8';%求转置

bn=str2num(b(:))';%待传二进制比特 Rb=100;%码元速率

N0=0.000002;%噪声单边功率谱密度 fs=4000; miu=0;

sigma=sqrt(N0*fs/2); t=linspace(0,N/Rb,N/Rb*fs); M=N/Rb*fs; fc=1000; dn=[];

dn(1)=bitxor(1,bn(1)); for i=1:N-1

dn(i+1)=bitxor(dn(i),bn(i+1));%dn初值为1 end

N=length(dn); fm=N/5;%基带信号频率

L=800;

%%%%%%%%%%%%%%%%%%%%%%%%%%%

号%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% st1=t; for n=1:N if bn(n)<1;

for m=M/N*(n-1)+1:n*M/N st1(m)=0; end else

for m=M/N*(n-1)+1:M/N*n st1(m)=1; end end end st2=t; for n=1:N if dn(n)<1;

for m=M/N*(n-1)+1:n*M/N st2(m)=0; end else

for m=M/N*(n-1)+1:M/N*n st2(m)=1; end end end figure; subplot(211);

plot(t(1:L),st2(1:L)); title('基带信号'); axis([0,L/fs,-2,2]); subplot(212); m=2*st2-1;

plot(t(1:L),m(1:L));

title('差分编码并经过电平转换'); axis([0,L/fs,-2,2]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

号%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

s1=cos(2*pi*fc*t);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

制%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% F1=m.*s1; figure; subplot(211);

plot(t(1:L),F1(1:L));

title('调制信号');

noise=normrnd(0,sigma,[1,M]); psk=F1+noise;

subplot(211);plot(t(1:L),psk(1:L)); title('接收信号,经过AWGN后'); subplot(212);

periodogram(psk,[],M,fs); title('接收信号功率谱');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%经

器%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

B1=fc-Rb; B2=fc+Rb;

hbpf1=fir1(20,[B1,B2]*2/fs); wbpf1=filter(hbpf1,1,psk);%系统输出

figure; st=wbpf1; subplot(211);

plot(t(1:L),st(1:L));

title('经过带通滤波器后的信号'); subplot(212);

periodogram(st,[],M,fs); title('带通后功率谱');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

制%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

st2=[zeros(1,fs/Rb),st(1:(length(st)-fs/Rb))];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%低

波%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% st=st.*st2;

figure; subplot(311);

plot(t(1:L),st(1:L)); title('差分调制后波形'); subplot(312);

hlpf2=fir1(40,[Rb]/(fs/2)); wlpf2=filter(hlpf2,1,st); st=wlpf2;

plot(t(1:L),st(1:L));

title('经过低通滤波器后的信号'); subplot(313);

periodogram(st,[],M,fs); title('低通后功率谱');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%决%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%d=t; d=(st<0);

figure; subplot(211); plot(t,st1);

axis([0,L/fs,-2,2]); title('基带波形'); subplot(212); plot(t,d);

axis([0,L/fs,-2,2]); title('抽样判决后波形');

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务