《GMSK系统的建模与仿真MATLAB程序.docx》由会员分享,可在线阅读,更多相关《GMSK系统的建模与仿真MATLAB程序.docx(9页珍藏版)》请在优知文库上搜索。
1、主程序:sr=256000.0;%符号率ml=l;%解调电平数br=sr.*ml;%比特率nd=100;%每次循环中的符号个数ebn=15;%信噪比IPOINT=8;%过采样点数%禽*mc流波器初始彳匕-*m食*irfn=21;%阶数B=0.25*sr;B2=0.6*sr;xh=gaussf(B,irfn,IPOINT,sr,l);%发送器流波器设计xh21=gaussf(B2,irfn,!POINT,sr,0);%接收器滤波器设计%育*衰落初始彳匕*合金食金合*tstp=lsrIPOINT;%时间辨别率itau=IO;%直达波形dlvl=01;n=6j;%瑞利衰落thl=O.O;itnd0=
2、nd*IPOINT4r100;itndl=1000);now1=1;fd=320;flat=1;%合*起先j算*合金/会*合会金金合*nloop=1000;%循环数noe=0;%错误数nod=0;%传送数据数目foriii=l:nloop产生*datal=rand(l,nd.*ml)0.5;%rand:builtinfunctionsubplot(4,2,l),stairs(datal);title(产生的原始信号)axis(0,50,-2,2);%*mm*GMSKIt*datall=2*datal-l;data2=oversamp(data11,length(data11),IPOINT);
3、data3=conv(data2,xh);SUbPlOt(4,2,2),PIOudata3);title(基带信号通过高斯白噪声后)th=zcros(l,length(data3)+1);ich2=zeros(1,length(data3)+l);qch2=zcros(l,length(data3)+1);forii=2:length(data3)+lth(l,ii)=th(l,ii-D+pi2*data3(l,ii-l)./!POINT;endich2=cos(th);qch2=sin(th);fich2=fft(ich2,800);fqch2=fft(qch2,800);subplot(4
4、,2,3),plot(abs(fich2);title(同相支路频谙);SUbPlOt(4,2,4),Pk)UabSUqCh2);title(正交支路频谱);%食*育育/食食食食衰减算0;endforn=2:2:nd*ml+1demoddata2(l,n)=ich5(l,n-l)*qch5(1,n)*cos(pi*(n)0;enddemodatal=demoddata2(1,2:nd*ml+l);subplot(4,2,7),stairs(demodata);axis(0,50,-2,21);title(鬼原波形);估计不错概率分*noe2=sum(abs(data1-demodata);no
5、d2=lcngth(data1);noe=noe+noe2;nod=nod+nod2;%*输出结果*bcr=noe/nod;fprintf(差错概率估计值=%fn,noenod);子程序:functionJiout,qout=compconv(idata,qdata,filter)iout=conv(idata,filter);qout=conv(qdata,filter);functioniout,qout=delay(idata,qdata,nsamp,idel)iout=zcros(l,nsamp);qout=zeros(1,nsamp);ifidel=Oiout(l:idel)=zer
6、os(1,idel);qout(kidcl)=zeros(1,idel);endiout(idel+1:nsamp)=idata(1:nsamp-idel);qout(idel+1:nsamp)=qdata(l:nsamp-idel);functioniout,qout,ramp,rcos,rsin=fade(idata,qdata,nsamp,tstp,fd,no,counter,flat)iffd=0.0ac=sqrt(1.0./(2.0.*(no+1);constant(ich)as=sqrt(1.0./(2.0.*no);constant(qch)ic=counter;pai=3.14
7、159265;wm=2.0.*pai.*fd;n=4.*no+2;ts=tstp;wmts=wm.*ts;paino=pai./no;xc=zeros(1,nsamp);xs=zeros(l,nsamp);ic=knsampl+ic;fornn=1:nocwn=cos(cos(2.0.*pai.*nn.n).*ic.*wmts);xc=xc+cos(paino.nn).*cwn;xs=xs+sin(paino.*nn),*cwn;endcwmt=sqrt(2.0).*cos(ic.*wmts);xc=(2.0.*xc+cwmt).*ac;xs=2.0.*xs.*as0;ramp=sqrt(xc
8、.A2+xs.A2);rcos=xc.ramp;rsin=xs.ramp;ifflat=1iout=sqrt(xc.A2+xs.A2).*idata(1:nsamp);qout=sqrt(xc.A2+xs.A2).*qdata(l:nsamp);elseiout=xc.*idata(1:nsamp)-XsJqdata(1.nsamp);qout=xs.*idata(1:nsamp)+XcJqdata(1.nsamp);endelseiout=idata;qout=qdata;endfunctionxh=gaussf(B,irfn,ipoint,sr,ncc)point=ipoint;tr=sr
9、;n=ipoint.*irfn;mid=(n./2)+1;fo=Bsqrt(2*log(2);fori=1:nicon=i-mid;ym=icon;xt=l2*(erf(-sqrt(2log(2)*pi*B*(ymipoint-l2)tr)+erf(sqrt(2log(2)*pi*B*(ymipoint+l2)tr);ifncc=0%inthecaseofreceiverxh(i)=xt;elseifncc=1%inthecaseoftransmitterxh(i)=xt;elseerror(,nccerror);endendfunctionout=oversamp(indata,nsymb,
10、sample)out=zeros(l,nsymb*sample);out(ksample:1+sample*(nsymb-1)=indata;functioniout,qout,ramp,rcos,rsi11l=sefade(idata,qdata,itau,dlvl,th,n,itn,n1,nsamp,tstp,fd,flat)iout=zeros(l,nsamp);qout=zeros(l,nsamp);total_attn=sum(10.(-1.0.*dlvl./10.0);fork=1:n1atts=10.(-0.05*dlvl(k);ifdlvl(k)=40.0atts=0.0;endtheta=th(k).*pi./180.0;(itmp,qtmp=delay(idata,qdata,nsamp,itau(k);itmp3,qtmp3,ramp,rcos,rsin)-fade(itmp,qtmp,nsamp,tstp,fd,n(k),itn(k),flat);iout=iout+atts.*itmp3./Sqrtftota1.attn);qout=qout+atts.*qtmp3./sqrt(total_attn);end