您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > msk调制matlab
%Program3-16%msk2_fading.m%%SimulationprogramtorealizeMSKtransmissionsystem%(underonepathfading)%%ProgrammedbyR.SawaiandH.Harada%%********************Preparationpart*************************************sr=256000.0;%Symbolrateml=1;%ml:Numberofmodulationlevelsbr=sr.*ml;%Bitratend=100;%Numberofsymbolsthatsimulatesineachloopebn0=15;%Eb/N0IPOINT=8;%Numberofoversamples%*******************Fadinginitialization********************%Ifyouusefadingfunctionsefade,youcaninitializeallofparameters.%Otherwiseyoucancommentoutthefollowinginitialization.%ThedetailedexplanationofallofvaliablesarementionedinProgram2-8.%Timeresolutiontstp=1/sr/IPOINT;%Arrivaltimeforeachmultipathnormalizedbytstp%Ifyouwouldliketosimulateunderonepathfadingmodel,youhaveonlytoset%directwave.itau=[0];%Meanpowerforeachmultipathnormalizedbydirectwave.%Ifyouwouldliketosimulateunderonepathfadingmodel,youhaveonlytoset%directwave.dlvl=[0];%Numberofwavestogeneratefadingforeachmultipath.%Innormalcase,morethansixwavesareneededtogenerateRayleighfadingn0=[6];%InitialPhaseofdelayedwave%Inthissimulationfour-pathRayleighfadingareconsidered.th1=[0.0];%Numberoffadingcountertoskipitnd0=nd*IPOINT*100;%Initialvalueoffadingcounter%Inthissimulationone-pathRayleighfadingareconsidered.%Thereforeonefadingcounterareneeded.itnd1=[3000];%Numberofdirectwave+Numberofdelayedwave%Inthissimulationone-pathRayleighfadingareconsiderednow1=1;%MaximumDopplerfrequency[Hz]%Youcaninsertyourfavoritevaluefd=320;%Youcandecidetwomodetosimulatefadingbychangingthevariableflat%flat:flatfadingornot%(1-flat(onlyamplitudeisfluctuated),0-nomal(phaseandamplitudearefluctutated)flat=1;%********************STARTCALCULATION*************************************nloop=1000;%Numberofsimulationloopsnoe=0;%Numberoferrordatanod=0;%Numberoftransmitteddataforiii=1:nloop%***************************Datageneration********************************data1=rand(1,nd*ml)0.5;%rand:builtinfunction%***************************MSKModulation********************************data11=2*data1-1;data2=oversamp2(data11,length(data11),IPOINT);th=zeros(1,length(data2)+1);ich2=zeros(1,length(data2)+1);qch2=zeros(1,length(data2)+1);forii=2:length(data2)+1th(1,ii)=th(1,ii-1)+pi/2*data2(1,ii-1)./IPOINT;endich2=cos(th);qch2=sin(th);%****************************AttenuationCalculation***********************spow=sum(ich2.*ich2+qch2.*qch2)/(nd*IPOINT);%sum:builtinfunctionattn=0.5*spow*sr/br*10.^(-ebn0/10);attn=sqrt(attn);%sqrt:builtinfunction%**********************Fadingchannel**********************%Generateddataarefedintoafadingsimulator[ifade,qfade]=sefade(ich2,qch2,itau,dlvl,th1,n0,itnd1,now1,length(ich2),tstp,fd,flat);%Updatafadingcounteritnd1=itnd1+itnd0;%*********************AddWhiteGaussianNoise(AWGN)**********************[ich3,qch3]=comb(ifade,qfade,attn);%addwhitegaussiannoisesyncpoint=1;ich5=ich3(syncpoint:IPOINT:length(ich3));qch5=qch3(syncpoint:IPOINT:length(qch3));%****************************MSKDemodulation*****************************demoddata2(1,1)=-1;fork=3:2:nd*ml+1demoddata2(1,k)=ich5(1,k)*qch5(1,k-1)*cos(pi*(k))0;endforn=2:2:nd*ml+1demoddata2(1,n)=ich5(1,n-1)*qch5(1,n)*cos(pi*(n))0;end[demodata]=demoddata2(1,2:nd*ml+1);%**************************BitErrorRate(BER)****************************noe2=sum(abs(data1-demodata));%sum:builtinfunctionnod2=length(data1);%length:builtinfunctionnoe=noe+noe2;nod=nod+nod2;fprintf('%d\t%e\n',iii,noe2/nod2);%fprintf:builtinfunctionend%foriii=1:nloop%******************************Datafile***********************************ber=noe/nod;fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,noe/nod);%fprintf:builtinfunctionfid=fopen('BERmsk2fad.dat','a');fprintf(fid,'%d\t%e\t%f\t%f\t\n',ebn0,noe/nod,noe,nod);%fprintf:builtinfunctionfclose(fid);%********************endoffile***************************
本文标题:msk调制matlab
链接地址:https://www.777doc.com/doc-4671397 .html