收藏 分享(赏)

基于最小均方误差的-MMSE程序2.doc

上传人:yjrm16270 文档编号:6781257 上传时间:2019-04-22 格式:DOC 页数:6 大小:46KB
下载 相关 举报
基于最小均方误差的-MMSE程序2.doc_第1页
第1页 / 共6页
基于最小均方误差的-MMSE程序2.doc_第2页
第2页 / 共6页
基于最小均方误差的-MMSE程序2.doc_第3页
第3页 / 共6页
基于最小均方误差的-MMSE程序2.doc_第4页
第4页 / 共6页
基于最小均方误差的-MMSE程序2.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、MMSE 检测程序% m_sequence 程序一function mseq=m_sequence(fbconnection)n=length(fbconnection);N=2n-1;register=zeros(1,n-1) 1;mseq(1)=register(n);for i=2:Nnewregister(1)=mod(sum(fbconnection.*register),2);for j=2:nnewregister(j)=register(j-1);endregister=newregister;mseq(i)=register(n);end% %gold_seq.m (程序二)

2、function goldseq=gold_seq(fbconnection1,fbconnection2)mseq1=m_sequence(fbconnection1);mseq2=m_sequence(fbconnection2);N=2length(fbconnection1)-1;for shift_amount=0:N-1shift_mseq2=mseq2(shift_amount+1:N) mseq2(1:shift_amount);goldseq(shift_amount+1,:)=mod(mseq1+shift_mseq2,2);end% mmse_main (程序三)%MMS

3、E 解相关多用户检测器和 CD 传统多用户检测器的误码率比较(八个用户)clear all;snr_indb=1:8;for k=1:length(snr_indb)snr=10(snr_indb(k)/10);sgma=1;eb=2*(sgma2)*snr;LC=31;echip=eb/LC;N=10000;%number of bits transmitted%creat PN codesfbconnection=0 1 0 0 1; mseq=m_sequence(fbconnection); fbconnection1=0 0 1 0 1;fbconnection2=0 1 1 1 1

4、; goldseq=gold_seq(fbconnection1,fbconnection2); %N=2length(fbconnection)-1; ind1=find(mseq=0);mseq(ind1)=-1;ind2=find(goldseq=0);goldseq(ind2)=-1; %creat 31*31 gold sequencetemp=goldseq;pn_seq1=temp(3,:);pn_seq2=temp(4,:);pn_seq3=temp(7,:);pn_seq4=temp(10,:);pn_seq5=temp(15,:);pn_seq6=temp(20,:);pn

5、_seq7=temp(26,:);pn_seq8=temp(31,:);% comput matrix Rpp=pn_seq1;pn_seq2;pn_seq3;pn_seq4;pn_seq5;pn_seq6;pn_seq7;pn_seq8;RR=(1/LC)*pp*pp;RR1=inv(eb*eye(8);R=inv(RR+RR1); %检测器输出%generate codesfor i=1:Ntemp1=rand;if(temp10.5),dsource1(i)=-1;else dsource1(i)=1;end;temp2=rand;if(temp20.5),dsource2(i)=-1;

6、else dsource2(i)=1;end;temp3=rand;if(temp30.5),dsource3(i)=-1;else dsource3(i)=1;end;temp4=rand;if(temp40.5),dsource4(i)=-1;else dsource4(i)=1;end;temp5=rand;if(temp50.5),dsource5(i)=-1;else dsource5(i)=1;end;temp6=rand;if(temp60.5),dsource6(i)=-1;else dsource6(i)=1;end;temp7=rand;if(temp70.5),dsour

7、ce7(i)=-1;else dsource7(i)=1;end;temp8=rand;if(temp80.5),dsource8(i)=-1;else dsource8(i)=1;end;end;number_of_err=0;number_of_err1=0;number_of_err2=0;for i=1:N%将每个 bit repeat LC=31 timesfor j=1:LCrepeatdata1(j)=dsource1(i);repeatdata2(j)=dsource2(i);repeatdata3(j)=dsource3(i);repeatdata4(j)=dsource4(

8、i);repeatdata5(j)=dsource5(i);repeatdata6(j)=dsource6(i);repeatdata7(j)=dsource7(i);repeatdata8(j)=dsource8(i);end;for ii=0:28-1j=1;aa=ii;while aa=0bk(j,ii+1)=rem(aa,2);aa=floor(aa/2);j=j+1;endendbk=bk*2-1;%tranmit signal is:trans_sig1=sqrt(echip)* repeatdata1.*pn_seq1;trans_sig2=sqrt(echip)* repeat

9、data2.*pn_seq2;trans_sig3=sqrt(echip)* repeatdata3.*pn_seq3;trans_sig4=sqrt(echip)* repeatdata4.*pn_seq4;trans_sig5=sqrt(echip)* repeatdata5.*pn_seq5;trans_sig6=sqrt(echip)* repeatdata6.*pn_seq6;trans_sig7=sqrt(echip)* repeatdata7.*pn_seq7;trans_sig8=sqrt(echip)* repeatdata8.*pn_seq8;%add AWGN noise

10、noise=sgma*randn(1,LC);% receive signalfor j=1:LCrtemp(j)=trans_sig1(j)+trans_sig2(j)+trans_sig3(j)+trans_sig4(j)+trans_sig5(j)+trans_sig6(j)+trans_sig7(j)+trans_sig8(j);end;r=rtemp+noise;r1=r;r2=r;r3=r;r4=r;r5=r;r6=r;r7=r;r8=r;%CD JUDGEI1=sum(r1.*pn_seq1);I2=sum(r2.*pn_seq2);I3=sum(r3.*pn_seq3);I4=

11、sum(r4.*pn_seq4);I5=sum(r5.*pn_seq5);I6=sum(r6.*pn_seq6);I7=sum(r7.*pn_seq7);I8=sum(r8.*pn_seq8);% DD JUDGEI=R*I1,I2,I3,I4,I5,I6,I7,I8;y=I1,I2,I3,I4,I5,I6,I7,I8;for ii=1:28c(ii)=2*(bk(:,ii)*y-(bk(:,ii)*R*bk(:,ii); endm,mm=max(c);bb=bk(:,mm);if(bb(1)=dsource1(i),number_of_err2=number_of_err2+1;end;if

12、(bb(2)=dsource2(i),number_of_err2=number_of_err2+1;end;if(bb(3)=dsource3(i),number_of_err2=number_of_err2+1;end;if(bb(4)=dsource4(i),number_of_err2=number_of_err2+1;end;if(bb(5)=dsource5(i),number_of_err2=number_of_err2+1;end;if(bb(6)=dsource6(i),number_of_err2=number_of_err2+1;end;if(bb(7)=dsource7

13、(i),number_of_err2=number_of_err2+1;end;if(bb(8)=dsource8(i),number_of_err2=number_of_err2+1;end;% DD make decisionif(I(1)0), desion1=-1;else desion1=1;end;if(I(2)0), desion2=-1;else desion2=1;end;if(I(3)0), desion3=-1;else desion3=1;end;if(I(4)0), desion4=-1;else desion4=1;end;if(I(5)0), desion5=-1

14、;else desion5=1;end;if(I(6)0), desion6=-1;else desion6=1;end;if(I(7)0), desion7=-1;else desion7=1;end;if(I(8)0), desion8=-1;else desion8=1;end;if(desion1=dsource1(i),number_of_err=number_of_err+1;end;if(desion2=dsource2(i),number_of_err=number_of_err+1;end;if(desion3=dsource3(i),number_of_err=number

15、_of_err+1;end;if(desion4=dsource4(i),number_of_err=number_of_err+1;end;if(desion5=dsource5(i),number_of_err=number_of_err+1;end;if(desion6=dsource6(i),number_of_err=number_of_err+1;end;if(desion7=dsource7(i),number_of_err=number_of_err+1;end;if(desion8=dsource8(i),number_of_err=number_of_err+1;end;%

16、CD MAKE DECISION% CD make decisionif(I10), desion11=-1;else desion11=1;end;if(I20), desion21=-1;else desion21=1;end;if(I30), desion31=-1;else desion31=1;end;if(I40), desion41=-1;else desion41=1;end;if(I50), desion51=-1;else desion51=1;end;if(I60), desion61=-1;else desion61=1;end;if(I70), desion71=-1

17、;else desion71=1;end;if(I80), desion81=-1;else desion81=1;end;if(desion11=dsource1(i),number_of_err1=number_of_err1+1;end;if(desion21=dsource2(i),number_of_err1=number_of_err1+1;end;if(desion31=dsource3(i),number_of_err1=number_of_err1+1;end;if(desion41=dsource4(i),number_of_err1=number_of_err1+1;en

18、d;if(desion51=dsource5(i),number_of_err1=number_of_err1+1;end;if(desion61=dsource6(i),number_of_err1=number_of_err1+1;end;if(desion71=dsource7(i),number_of_err1=number_of_err1+1;end;if(desion81=dsource8(i),number_of_err1=number_of_err1+1;end;enderr(k)=number_of_err/(3*N)%MMSE bererr1(k)=number_of_err1/(3*N)%CD bererr2(k)=number_of_err2/(3*N)endsemilogy(snr_indb,err,k-o);%MMSE bergrid on;hold on;semilogy(snr_indb,err1,r-+);%CD berhold on

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报