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