DS-CDMA

上传人:206****923 文档编号:91846756 上传时间:2019-07-02 格式:DOC 页数:15 大小:38.52KB
返回 下载 相关 举报
DS-CDMA_第1页
第1页 / 共15页
DS-CDMA_第2页
第2页 / 共15页
DS-CDMA_第3页
第3页 / 共15页
DS-CDMA_第4页
第4页 / 共15页
DS-CDMA_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《DS-CDMA》由会员分享,可在线阅读,更多相关《DS-CDMA(15页珍藏版)》请在金锄头文库上搜索。

1、Simulation program to realize DS-CDMA system% dscdma.m% Programmed by yixiongshu,2006.8.9clear all;clc;%-preparation part -sr=256000.0; % symboll rateml=2; % number of modulation levelsbr=sr*ml; % bit ratend=100; % number of symbolebno=8; % Ebno%-Filter initialization-irfn=21;IPOINT=8;alfs=0.5;xh=hr

2、ollfcoef(irfn,IPOINT,sr,alfs,1); % Transmitting Filterxh2=hrollfcoef(irfn,IPOINT,sr,alfs,0); % Received Filter%- Spreading code initialization-user=1; % number of usersseq=1; % 1:m-sequence 2:Gold 3:orthogonal Goldstage=3;ptap1=1 3;ptap2=2 3;regi1=1 1 1;regi2=1 1 1;% - Generation of the spreading co

3、de -switch seq case 1 code=mseq(stage,ptap1,regi1,user); case 2 m1=mseq(stage,ptap1,regi1); m2=mseq(stage,ptap2,regi2); code=goldseq(m1,m2,user); case 3 m1=mseq(stage,ptap1,regi1); m2=mseq(stage,ptap2,regi2); code=goldseq(m1,m2,user),zeros(user,1);endcode=code*2-1;clen=length(code);% - Fading initia

4、lization -rfade=0; % Rayleigh fading 0:nothing 1:consideritau=0,8; % delay timedlvl1=0.0,40.0; % attenuation leveln0=6,7;th1=0.0,0.0;itnd1=3001,4004;now1=2;tstp=1/sr/IPOINT/clen; % time resolutionfd=160;flat=1;itnde1=nd*IPOINT*clen*30;% - Start calculation -nloop=1000;noe=0;nod=0;for ii=1:nloop % -

5、Transmitter - data=rand(user,nd*ml)0.5; ich,qch=qpskmod(data,user,nd,ml); ich1,qch1=spread(ich,qch,code); ich2,qch2=compoversamp2(ich1,qch1,IPOINT); ich3,qch3=compconv2(ich2,qch2,xh); if user=1 ich4=ich3; qch4=qch3; else ich4=sum(ich3); qch4=sum(qch3); end% - Fading channel -if rfade=0 ich5=ich4; qc

6、h5=qch4;else ich5,qch5=sefade(ich4,qch4,itau,dlvl1,th1,n0,itnd1,. now1,length(ich4),tstp,fd,flat); itnd1=itnd1+itnde1;end% - Receiver -spow=sum(rot90(ich3.2+qch3.2)/nd;attn=sqrt(0.5*spow*sr/br*10(-ebno/10);ich6,qch6=comb2(ich5,qch5,attn);ich7,qch7=compconv2(ich6,qch6,xh2); % filtersamp1=irfn*IPOINT+

7、1;ich8=ich7(:,samp1:IPOINT:IPOINT*nd*clen+samp1-1);qch8=qch7(:,samp1:IPOINT:IPOINT*nd*clen+samp1-1);ich9 qch9=despread(ich8,qch8,code);demodata=qpskdemod(ich9,qch9,user,nd,ml); % QPSK demodulation%- BER -noe2=sum(sum(abs(data-demodata);nod2=user*nd*ml;noe=noe+noe2;nod=nod+nod2;% fprintf(%dt%en,ii,no

8、e2/nod2);end% -Data file -ber=noe/nod;fprintf(%dt%dt%dt%en,ebno,noe,nod,ber);fid=fopen(BER.mat,a);fprintf(fid,%dt%dt%dt%en,ebno,noe,nod,ber);fclose(fid);% - end of file -% Program 5-11% comb2.m% Function to add white gaussian noise.% Programmed by yixiongshu.2006.8.9function iout,qout=comb2(idata,qd

9、ata,attn)% attn: attenuation level causedby ebno or C/N%v=length(idata);h=length(attn);iout=zeros(h,v);qout=zeros(h,v);for ii=1:h iout(ii,:)=idata+randn(1,v)*attn(ii); qout(ii,:)=qdata+randn(1,v)*attn(ii);end % end of file.% Program 5-10% compconv2.m% Function to perform convolution between signal a

10、nd filter.% Programmed by yixiongshu,2006.8.9function iout,qout=compconv2(idata,qdata,filter)% : filter tap coefficients.iout=conv2(idata,filter);qout=conv2(qdata,filter);% end of file.% Program 5-9% compoversamp2.m% Function to sample sampletime% programmed by yixiongshu.2006.8.9function iout,qout=

11、compoversamp2(iin,qin,sample)% iin : input Ich sequence% qin :input Qch sequence% iout: ich output data sequence% qout : qch output data sequence% sample : Number of oversamples.%-h,v=size(iin);iout=zeros(h,v*sample);qout=zeros(h,v*sample);iout(:,1:sample:1+sample*(v-1)=iin;qout(:,1:sample:1+sample*(v-1)=qin;% end of file.% Program 5-1% autocorr.m% % Autocorrelation function of a sequence% Programmed by yixoingshu,2007.8.9%function out=autocorr(indata,tn)% indata: input sequence% tn : number of period% out : atuocorrelation data%-

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号