您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > MATLAB仿真-BPSK调制
matlabBPSK调制与解调1、调制clearall;g=[10101001];%基带信号f=100;%载波频率t=0:2*pi/99:2*pi;cp=[];sp=[];mod=[];mod1=[];bit=[];forn=1:length(g);ifg(n)==0;die=-ones(1,100);%Modulantese=zeros(1,100);%elseg(n)==1;die=ones(1,100);%Modulantese=ones(1,100);%endc=sin(f*t);cp=[cpdie];mod=[modc];bit=[bitse];endbpsk=cp.*mod;subplot(2,1,1);plot(bit,'LineWidth',1.5);gridon;title('BinarySignal');axis([0100*length(g)-2.52.5]);subplot(2,1,2);plot(bpsk,'LineWidth',1.5);gridon;title('ASKmodulation');axis([0100*length(g)-2.52.5]);2、调制解调加噪声clc;closeall;clear;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%假定:%2倍载波频率采样的bpsk信号%调制速率为在波频率的N/2m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%m=128;N=512;n=1:1:N;N0=0.5*randn(1,N)%噪声h0=zeros(1,N);%30阶低通滤波器h0f=[00.30.31];w0=[1100];b=fir2(30,f,w0);[h,w]=freqz(b,1,N/2);h0(1,1:N/2)=abs(h');fori=1:N/2h0(1,N-i+1)=h0(1,i);end;%%%%%%%%%随机序列a=rand(1,m);fori=1:mif(a(1,i)0.5)a(1,i)=1;elsea(1,i)=-1;end;end;%%%生成BPSK信号bpsk_m=zeros(1,N);j=1;k=1;fori=1:Nif(j==(N/m+1))j=1;k=k+1;end;%0.05*pi为初始相位,可以任意改变bpsk_m(1,i)=a(1,k)*sin(2*pi*0.5*i+0.05*pi)+a(1,k)*cos(2*pi*0.5*i+0.05*pi);j=j+1;end;bpsk_m=bpsk_m+N0;%信号加噪声,模拟过信道%接收处理用正交本振与信号相乘,变频bpsk_m1=bpsk_m.*sin(2*pi*0.5*n);bpsk_m2=bpsk_m.*cos(2*pi*0.5*n);%滤波tempx=fft(bpsk_m1);tempx=tempx.*h0;%低通滤波tempx=ifft(tempx);real_x=real(tempx);tempx=h0.*fft(bpsk_m2);tempx=tempx.*h0;%低通滤波tempx=ifft(tempx);real_x1=real(tempx);subplot(2,1,1);plot(real_x1+real_x,'b');axis([1N-2.52.5]);gridon;holdon;In=real_x1+real_x;%可只取一路,这里取了两路之和fori=1:N%滤波后整形if(In(1,i)0)%判决,得到解调结果In(1,i)=1;elseIn(1,i)=-1;end;end;plot(In,'r');an=zeros(1,m);fori=1:man(1,i)=In(1,(i-1)*N/m+N/(2*m));end;subplot(2,1,2);%比较误码plot(an,'r*');holdon;axis([1m-22]);plot(a,'b^');
本文标题:MATLAB仿真-BPSK调制
链接地址:https://www.777doc.com/doc-1736823 .html