資源描述:
《dscdma仿真源程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、%main_DSCDMA.m%這個仿真程序用于實現(xiàn)DS-CDMA通信系統(tǒng)仿真%%+++++++++++++++++++++++準備咅盼+++++++++++++++++++++++++++clearall;sr=256000.0;%符號速率ml=2;%調(diào)制階數(shù)br=sr*ml;%比特速率nd=100;%符號數(shù)SNR二5:1:10;%Eb/No%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%+++++++++++++++++++++濾波器初值設(shè)定++++++++
2、+++++++++++++++irfn=21;%濾波器階數(shù)IPOINT=&%過采樣倍數(shù)alfs=0.5;%滾降因子[xh]=hrollfcoef(irfn,IPOINT,sr,alfs,1);[xh2]=hrollfcoef(irfn,IPOINT,sr,alfs,0);%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%++++++++++++++++++++++++jj^弓馬設(shè)定+++++++++++++++++++user=1;%用戶數(shù)seq=1;%l:m序
3、列2:Gold序歹ij3:正交Gold序列stage=3;%序列階數(shù)ptapl=[13];%第一個線性移位寄存器的系數(shù)ptap2=[23];%第二個線性移位寄存器的系數(shù)regil=[111];%第一個線性移位寄存器的初始化regi2=[111];%第二個線性移位寄存器的初始化%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++disp('start');%+++++++++++++++++擴頻碼的產(chǎn)生+++++++++++++++++forebn0=-5:l:10s
4、witchseqcase1%m序列code=mseq(stage,ptap1,regi1,user);case2%Gold序列m1=mseq(stage,ptap1,regil);%正交Gold序列m2=mseq(stage,ptap2,regi2);code=goldseq(m1,m2,user);case3m1=mseq(stage,ptap1,regi1);m2=mseq(stage,ptap2,regi2);code=[goldseq(ml,m2,user),zeros(user,1)];endcode=code*2-1;clen=
5、length(code);%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%+++++++++++++++++++++f右+++++++++++++++++++++++rfade=0;%瑞利衰減0:不考慮1:考慮itau=[0,8];%延時dlvl1=[0.0,40.0];%衰減電平nO=67];%用于產(chǎn)生衰落的波數(shù)thl=[0.0,0.0];%延遲波形的初始相位itndl=[3001,4004];%設(shè)置衰落計數(shù)nowl=2;%主徑和延遲波形總數(shù)tstp=1/s
6、r/IPOINT/clen;%時間分辨率fd=160;%多普勒頻移[Hz]flat=1;%平坦瑞利衰落環(huán)境itndel=nd*IPOINT*clen*30;%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%++++++++++++++++++++++>f^真女臺++++++++++++++++++++++++nloop=1000;%仿真循環(huán)次數(shù)noe=0;nod=0;forii=l:nloop%++++++++++++++++++++++++++++++++++
7、+++++++++++++++++++++++++++++%++++++++++++++++++++++++發(fā)射機++++++++++++++++++++++++++++data=rand(user,nd*ml)>0.5;[ich,qch]=qpskmod(data,user,nd,ml);%QPSK調(diào)制[ich1,qch1]=spread(ich,qch,code);%擴頻[ich2,qch2]=compoversamp2(ich1,qchlJPOINT);%過采樣[ich3,qch3]=compconv2(ich2,qch2,xh);%
8、濾波ifuser==1ich4=ich3;qch4=qch3;elseich4HSum(ich3)_qch4uSum(qch3)八end%++++++++++++++++++++