基于MATLAB的IS-95系统仿真

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

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

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

资源描述

1CDMA期末论文基于MATLAB的IS-95系统仿真课程名称CDMA蜂窝移动通信姓名学号专业成绩任课老师上课学期21作业要求分析给出的源程序,逐行给出中文注释,并分析仿真结果。按照如图1所示的框图设计一个CDMA系统,并进行仿真。信源卷积编交织编扩频加扰调制AWGN信道解调解扰信宿解卷积解交织解扩图1CDMA系统框图2题目一2.1源程序注释2.1.1主程序部分%main_CDMA_forward.m%此函数用于IS-95前向链路系统的仿真,包括扩%频调制,匹配滤波,RAKE接收等相关通信模块。%但没有在频带上进行调制仿真。%仿真环境:加性高斯白噪声信道.%数据速率=9600KBps%clearallcloseallclcdisp('--------------start-------------------');%定义通信仿真全局变量globalZiZqZsshowRGiGq%ZiI支路扩频PN序列生成器状态%ZQQ支路扩频PN序列生成器状态%Zs扰码PN序列生成器状态%show指示是否画出仿真过程各部分产生的输出3%R仿真时码元宽度%GiI支路扩频PN序列%GqQ支路扩频PN序列clearj;show=0;SD=0;%选择软/硬判决接收%-------------------主要的仿真参数设置------------------%信道数据率为9600bpsBitRate=9600;%码片速率为1.2288MHzChipRate=1228800;%消息码元个数N=184;%匹配滤波器类型--升余弦MFType=1;R=5;%+++++++++++++++++++Viterbi生成多项式++++++++++++++++++%维特比译码器(译卷积码)G_Vit=[111101011;101110001];%生成矩阵的长度K=size(G_Vit,2);%输出码片数L=size(G_Vit,1);%++++++++++++++++++++++++++++++++++++++++++++++++++++++%++++++++++++++++++++++Walsh矩阵++++++++++++++++++++++++%规定需要的Walsh序列长度WLen=64;%生成64bitWalsh序列[1010.....]Walsh=reshape([1;0]*ones(1,WLen/2),WLen,1);%Walsh=zeros(WLen,1);%++++++++++++++++++++++++++++++++++++++++++++++++++++++%++++++++++++++++++扩频调制PN码的生成多项式++++++++++++++%Gi=[1010001110100001]';%Gq=[1001110001111001]';%I信道扩频PN序列生成多项式Gi_ind=[15,13,9,8,7,5,0]';%I信道扩频PN序列生成多项式Gq_ind=[15,12,11,10,6,5,4,3,0]';%初始化序列Gi(16bit,全零)Gi=zeros(16,1);%根据生成多项式Gi_ind将对应位置1Gi(16-Gi_ind)=ones(size(Gi_ind));%初始化I路信道PN码生成器的初始状态Zi=[zeros(length(Gi)-1,1);1];%初始化序列Gi(16bit,全零)Gq=zeros(16,1);%根据生成多项式Gq_ind将对应位置1,得到二进制生成多项式4Gq(16-Gq_ind)=ones(size(Gq_ind));%Q路信道PN码生成器的初始状态Zq=[zeros(length(Gq)-1,1);1];%++++++++++++++++++++++++++++++++++++++++++++++++++++++%+++++++++++++++++++扰码生成多项式++++++++++++++++++++++%扰码序列生成多项式Gs_ind=[42,35,33,31,27,26,25,22,21,19,18,17,16,10,7,6,5,3,2,1,0]';%初始化序列GsGs=zeros(43,1);%根据生成多项式Gs_ind将对应位置1,得到二进制生成多项式Gs(43-Gs_ind)=ones(size(Gs_ind));%长序列生成器的初始状态Zs=[zeros(length(Gs)-1,1);1];%++++++++++++++++++++++++++++++++++++++++++++++++++++++%++++++++++++++++++++++AWGN信道++++++++++++++++++++++++%扩频增益EbEc=10*log10(ChipRate/BitRate);%EbEcVit=10*log10(L);%仿真信噪比范围(dB)%EbNo=[-2:0.5:6.5];EbNo=[-2:0.5:4];%++++++++++++++++++++++++++++++++++++++++++++++++++++++%------------------------------------------------------%-------------------------主程序-------------------------%初始化向量ErrorsB=[];ErrorsC=[];NN=[];%ErrorsB%ErrorsC%NN%输出信息说明采用的维特比译码判决类型if(SD==1)fprintf('\nSOFTDecisionViterbiDecoder\n\n');elsefprintf('\nHARDDecisionViterbiDecoder\n\n');end%对信噪比范围内每个数字进行仿真fori=1:length(EbNo)%输出当前仿真信噪比fprintf('\nProcessing%1.1f(dB)',EbNo(i));iter=0;%仿真计数器ErrB=0;%出错的比特数(编码前)ErrC=0;%出错的子码数(编码后)while(ErrB300)&(iter150)%当误码数超过或者循环试验150次以上才可以统计误码率%激活命令窗口drawnow;%++++++++++++++++++++++发射机+++++++++++++++++++++++5%生成信息码元(由高斯白噪声经过零比较得到)TxData=(randn(N,1)0);%输出已编码、交织并加扰的消息比特与所用到的扰码%(码率:19.2kbps)[TxChips,Scrambler]=PacketBuilder(TxData,G_Vit,Gs);%下面进行扩频调制,调制后码率为1.2288Mcps[xPNMF]=Modulator(TxChips,MFType,Walsh);%++++++++++++++++++++++++++++++++++++++++++++++++++++++%+++++++++++++++++++++++++++++++++++++++++++++++++%信道产生高斯白噪声noise=1/sqrt(2)*sqrt(R/2)*(randn(size(x))+j*randn(size(x)))*10^(-(EbNo(i)-EbEc)/20);%j*randn(size(x)))*10^(-(EbNo(i)-EbEc)/20);%向已调信号中混入加性高斯白噪声r=x+noise;%++++++++++++++++++++++++++++++++++++++++++++++++++++++%+++++++++++++++++++++++++接收机++++++++++++++++++++++++%软判决,输出速率为19.2Kcps经过卷积编码的序列RxSD=Demodulator(r,PN,MF,Walsh);%对Rake接收机解调后的信号进行过零比较RxHD=(RxSD0);if(SD)%如果选择了软判决则会进行软判决,%并进行解扰、解交织维特比译码[RxDataMetric]=ReceiverSD(RxSD,G_Vit,Scrambler);else%进行硬判决,并进行解扰、解交织维特比译码[RxDataMetric]=ReceiverHD(RxHD,G_Vit,Scrambler);end%++++++++++++++++++++++++++++++++++++++++++++++++++++++if(show)%画出软判决输出结果subplot(311);plot(RxSD,'-o');title('SoftDecisions');%将判决结果与发送序列异或,显示出错码(维特比译码前)subplot(312);plot(xor(TxChips,RxHD),'-o');title('ChipErrors');%将收发数据进行异或,显示出错码subplot(313);plot(xor(TxData,RxData),'-o');title(['DataBitErrors.Metric=',num2str(Metric)]);pause;endif(mod(iter,50)==0)%如果已循环次数为50的倍数则打印‘.’将变量保存fprintf('.');%将变量保存到硬盘6saveTempResultsErrBErrCNiterend%计算编码前,解码后出错的消息比特(9600Bps)数量ErrB=ErrB+sum(xor(RxData,TxData));%计算经过编码出错的子码(19.2kBps)数ErrC=ErrC+sum(xor(RxHD,TxChips));%循环次数加1iter=iter+1;end%生成误比特数向量ErrorsB=[ErrorsB;ErrB];%生成误码数向量ErrorsC=[ErrorsC;ErrC];%计算本次共仿真的消息比特数NN=[NN;N*iter];%保存所有产生的数据saveSimData*end%+++++++++++++++++++++++++误码率计算++++++++++++++++++++++++%计算误码率(卷积编码前的信号)PerrB=ErrorsB./NN;%PerrB1=ErrorsB1./NN1;%计算误码率(卷积编码后的信号)PerrC=ErrorsC./NN;%BPSK调制理论误码率(无卷积编码与扩频)Pbpsk=1/2*erfc(sqrt(10.^(EbNo/10)));%有维特比译码但无扩频的理论误码率PcVit=1/2*erfc(sqrt(10.^((EbNo-EbEcVit)/10)));%有扩频但无维特比译码的理论误码率Pc=1/2*erfc(sqrt(10.^((EbNo-EbEc)/10)));%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%%+++++++++++++++++++++++++性能仿真显示++++++++++++++++++++++figure;semilogy(EbNo(1:length(PerrB)),PerrB,'b-*');holdon;%%semilogy(EbNo(1:length(PerrB1)),PerrB1,'k-o');%holdon;semilogy(EbNo(1:length(PerrC)),PerrC,'b-o');gridon;semilogy(EbNo,Pbpsk,'b-.^');semilogy(EbNo,PcVit,'k-.x');ylabel('BER');semilogy(EbNo,Pc,'b-.x');xlabel('信噪比/dB');ylabel('误码率');%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++disp('--------------end-------

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

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

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

×
保存成功