《BPSK调制解调及误码率的计算.doc》由会员分享,可在线阅读,更多相关《BPSK调制解调及误码率的计算.doc(3页珍藏版)》请在三一办公上搜索。
1、%随机产生码元clcclear allnum=10;%码元个数ek=round(rand(1,num,1);%产生载波t=0:2*pi/999:2*pi;%周期num1=1000;%个数 len=length(t);c=-sin(t);%调制ektemp=;ctemp=;for n=1:numif ek(n)=0 ctemp=ctemp,-c; a=zeros(1,len); ektemp=ektemp,a; elseif ek(n)=1ctemp=ctemp,c; a=ones(1,len); ektemp=ektemp,a; endendsubplot(2,1,1); %分别画出原信号、已
2、调信号示意plot(ektemp,LineWidth,1.5);title(原码元);grid on;axis(0 num1*num -2.5 2.5);subplot(2,1,2);plot(ctemp,LineWidth,1.5);title(已调信号);grid on;axis(0, num1*num, -2.5, 2.5);%相干解调%本地载波loca=;for n=1:num loca=loca,c;%此处c的正负决定解调后是否倒piend locb=loca;%相乘locc=2*ctemp.*locb;%低通滤波器b,a = BUTTER(3,2*pi*0.0003,low); %
3、信号频率为0.001locd=filter(b,a,locc);%低通滤波后的信号figure;subplot(2,1,1); %相乘后的波形plot(locc,LineWidth,1.5);title(相乘后的信号);grid on;axis(0 num1*num -2.5 2.5 );dd=locd+randn(1,10000);%低通滤波后的信号波形图subplot(2,1,2);plot(dd,LineWidth,1.5);title(低通滤波后的信号);grid on;axis(0 num1*num -2.5 2.5 );%抽样判决for i=1:num1*num if(locd(i
4、)0) %判决,得到解调结果 locd(i)=1; else locd(i)=-1; endendfigure;subplot(2,1,1); %分别画出原信号、解调后信号示意plot(ektemp,LineWidth,1.5);title(原码元)grid on;axis(0 num1*num -2.5 2.5);subplot(2,1,2);plot(locd,LineWidth,1.5);title(解调后的信号);grid on;axis(0 num1*num -2.5 2.5 );p=symerr(ektemp,locd)/10 %误码率%误码率曲线figure(4)r=0:2:10;rr=10.(r/10);pe1=1/2*exp(-rr);%相干解调的误码率曲线hold onplot(r,pe1,r);grid on;pe2=(1-1/2*erfc(sqrt(rr).*erfc(sqrt(rr);%差分相干解调的误码率曲线plot(r,pe2,b);xlabel(bpsk,dpsk误码率曲线);set(gca,XTick,-6:3:18);