您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > (完整版)MATLAB模拟2ASK调制误码率与信噪比关系曲线的程序
%模拟2ASK%Pe=zeros(1,26);jishu=1;forsnr=-10:0.5:15max=10000;s=round(rand(1,max));%长度为max的随机二进制序列f=100;%载波频率nsamp=1000;每个载波的取样点数tc=0:2*pi/999:2*pi;tc的个数应与nsamp相同cm=zeros(1,nsamp*max);cp=zeros(1,nsamp*max);mod=zeros(1,nsamp*max);forn=1:max;ifs(n)==0;m=zeros(1,nsamp);b=zeros(1,nsamp);elseifs(n)==1;m=ones(1,nsamp);b=ones(1,nsamp);endendc=sin(f*tc);cm((n-1)*nsamp+1:n*nsamp)=m;cp((n-1)*nsamp+1:n*nsamp)=b;mod((n-1)*nsamp+1:n*nsamp)=c;endtiaoz=cm.*mod;%2ASK调制t=linspace(0,length(s),length(s)*nsamp);tz=awgn(tiaoz,snr);%信号tiaoz中加入白噪声,信噪比为SNR=10dBjiet=2*mod.*tz;%相干解调[N,Wn]=buttord(0.2,0.3,1,15);[b,a]=butter(N,Wn);dpsk=filter(b,a,jiet);%低通滤波%抽样判决,判决门限为0.5depsk=zeros(1,nsamp*max);form=nsamp/2:nsamp:nsamp*max;ifdpsk(m)0.5;fori=1:nsampdepsk((m-500)+i)=0;endelseifdpsk(m)=0.5;fori=1:nsampdepsk((m-500)+i)=1;endendendendwrong=0;fori=1:length(cp);ifcp(i)~=depsk(i);wrong=wrong+1;endendPe(jishu)=wrong/length(cp);jishu=jishu+1;endsnr=-10:0.5:15;semilogy(snr,Pe,'*');%理论计算snr=-10:0.1:15;Pet=0.5*erfc((10.^(snr/10)/4).^0.5);holdon;semilogy(snr,Pet);xlabel('SNR/dB');ylabel('P_e');legend('模拟结果','理论值');
本文标题:(完整版)MATLAB模拟2ASK调制误码率与信噪比关系曲线的程序
链接地址:https://www.777doc.com/doc-6463638 .html