sim-qpskgray-multipath

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

%QPSKsimulationwithGraycodingandsimpleRayleigh(noLOS)multipathandAWGNadded%Runfromeditordebug(F5)%JC-7/1/08%Thepurposeofthism-fileistoshowabasebandsimulatedversionofQPSKwith%Graycoding(RayleighmultipathandAWGNadded)whichmaygivevalidresults%(stilltryingtofigureoutifthisprogramiscorrect-multipathsosubjective)%whencomparedtotheoritical/simulatedAWGNMPSKanalysisSERandBER.%Thesimulationassumesasinglechannel(nodiversityorFECcodesotherthanGray)%perfectsystemwithperfectsyncandnointersymbolinterference.Theprogramcontains%noRootRaisedCosineorRaisedCosinefiltersastheywouldjustadddelay.Ihope%itwillbeusefultootherstoplaywithandgiveabasicunderstandingoftheproblems%encounteredinthechannelwithvarioustypesofmultipath.%Ihaveprovidedcomments,notesandreferencesforreview.Youcanalso%downloadthefilesim_qpskgray.munderJCfileforBERandSERsimulation%onlyinAWGNchannel.Whatthisallprovesisthatyouneedatleast17dB%offademarginat10-3BERwithRayleighmultipathwhencomparingonlywithAWGN%atSNRof7to8dB.Ofcourseyoucanlowerthiswithantennadiversity,FECcodes,etc%orpossiblywithDSSSwithpsuedorandomcodesIfyouhavethecommunicationstoolbox%youcanmakecomparisonswithwhatitgivesinit'splots(seereferences)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%TRANSMITTER%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear%randn('state',0);%keepsbitsthesameonrerunsnr_data_bits=10000;%0'sand1's,keepevennumber-Takes~1minuteforarunof1million%64000allowsbitsandcomplexvaluestobeshowninarrayeditornr_symbols=nr_data_bits/2;b_data=(randn(1,nr_data_bits).5);%random0'sand1'sb=(b_data);%MapthebitstobetransmittedintoQPSKsymbolsusingGraycoding.The%resultingQPSKsymboliscomplex-valued,whereoneofthetwobitsineach%QPSKsymbolaffectstherealpart(Ichannel)ofthesymbolandtheother%bittheimaginarypart(Qchannel).Eachpartissubsequently%modulatedtoformthecomplex-valuedQPSKsymbol.%%TheGraymappingresultingfromthetwobranchesareshownwhere%onesymbolerrorcorrespondstoonebiterrorgoingcounterclockwise.%imaginarypart(Qchannel)%^%|%10x|x00(oddbit,evenbit)%|%-------+-------realpart(Ichannel)%|%11x|x01%|%Input:%b=bits{0,1}tobemappedintoQPSKsymbols%%Output:%d=complex-valuedQPSKsymbols0.70711+0.70711i,etcd=zeros(1,length(b)/2);%definitionoftheQPSKsymbolsusingGraycoding.forn=1:length(b)/2p=b(2*n);imp=b(2*n-1);if(imp==0)&&(p==0)d(n)=exp(j*pi/4);%45degreesendif(imp==1)&&(p==0)d(n)=exp(j*3*pi/4);%135degreesendif(imp==1)&&(p==1)d(n)=exp(j*5*pi/4);%225degreesendif(imp==0)&&(p==1)d(n)=exp(j*7*pi/4);%315degreesendendqpsk=d;SNR=0:30;%changeSNRvaluesBER1=[];SNR1=[];SER=[];SER1=[];sigma1=[];%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Rayleighmultipath/AWGN(AdditiveWhiteGaussianNoise)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%forSNR=0:length(SNR);%loopoverSNR-changeSNRvalues(0,5,10etcdB)sigma=sqrt(10.0^(-SNR/10.0));sigma=sigma/2;%Requiredadivisionby2togetclosetoexactsolutions(Notes)-WHY?%Isdividingbytwo(2)legitimate?%sigma1=[sigma1sigma];%addRayleighmultipath(noLOS)tosignal(qpsk)x=randn(1,nr_symbols);y=randn(1,nr_symbols);ray=sqrt(0.5*(x.^2+y.^2));%variance=0.5-TrackstheoriticalPDFcloselympqpsk=qpsk.*ray;%addnoisetoQPSKGraycodedsignalswithmultipathmpsnqpsk=(real(mpqpsk)+sigma.*randn(size(mpqpsk)))+i.*(imag(mpqpsk)+sigma.*randn(size(mpqpsk)));%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Receiver%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%r=mpsnqpsk;%receivedsignalplusnoiseandmultipath%Detector-WhenGraycodingisconfiguredasshown,thedetectionprocess%becomesfairlysimpleasshown.AsystemwithoutGraycodingrequiresamuch%morecomplexalgorithimdetectionmethodbhat=[real(r)0;imag(r)0];%detectorbhat=bhat(:)';bhat1=bhat;%0'sand1'sne=sum(b~=bhat1);%numberoferrorsBER=ne/nr_data_bits;SER=ne/nr_symbols;%considerthistobePs=log2(4)*Pb=2*PbSER1=[SER1SER];BER1=[BER1BER];SNR1=[SNR1SNR];end%Notes:TheoriticalQPSKEXACTSOLUTIONforseveralSNR=Eb/NopointsonBER/SERplot%AssumingGraycodingandAWGN%Pb=Q(sqrt(2SNRbit))%Ps=2Q(sqrt(2SNRbit))[1-.5Q(sqrt(2SNRbit))]%SNR=7dB%SNRbit=10^(7/10)=5.0118getratio%Pb=Q(sqrt(2*SNRbit))=Q(sqrt(10.0237))=7.7116e-4(biterrorrate)%whereQ=.5*erfc(sqrt(10.0237)/1.414)%Ps=2*Q-Q^2=2*(7.7116e-4)-(7.7116e-4)^2=1.5e-3(symbolerrorrate)%SNR=9dB%SNRbit=10^(9/10)=7.943getratio%Pb=Q(sqrt(2*SNRbit))=Q(sqrt(15.866))=3.37e-5(biterrorrate)%Ps=2*Q-Q^2=2*(3.37e-5)-(3.37e-5)^2=6.74e-5(symbolerrorrate)%0,1,2,3,4,5,6,8,10,11,12Youcandotherestofthesewithaloopandhold%orhandplotonSimulationofBER/SERforQPSKwithGraycoding%(RayleighmultipathandAWGN)graph2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Plots%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%figure(1);plot(d,'o');%plotconstellationwithoutnoiseaxis([-22-22]);gridon;xlabel('real');ylabel('imag');title('QPSKconstellation');figure(2);semilogy(SNR1,BER1,'*',SNR1,SER1,'o');gridon;xlabel('SNR=Eb/No(dB)');ylabel('B

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功