?? mud.m
字號(hào):
%在DS-spread spectrum系統(tǒng)中,噪聲為加性高斯白噪聲,傳統(tǒng)單用戶(hù)檢測(cè),線(xiàn)性解相關(guān)多用戶(hù)檢測(cè)和最小均方誤差多用戶(hù)檢測(cè)的性能比較clear allclose allclc;prompt={'Enter the numbers of user:','Enter the length of user code:','Enter the power of the user code','Enter the power of Noise','Enter the kth user which you want to test?'};name=['CDMA MUD TEST'];line=1;defaultanswer={'10','5000','1 2 3 4 5 6 7 8 9 10', '10','1'};glabel=inputdlg(prompt,name,line,defaultanswer);num1=str2num(char(glabel(1,1)));num2=str2num(char(glabel(2,1)));num3=str2num(char(glabel(3,1)));num4=str2num(char(glabel(4,1)));k=str2num(char(glabel(5,1)));UserNumber=num1;%用戶(hù)數(shù)inflength=num2;%用戶(hù)信息序列長(zhǎng)度a=num3; %用戶(hù)信息功率Pn=num4; %噪聲功率sigma=1;%噪聲標(biāo)準(zhǔn)差N=31;R=(ones(UserNumber)+(N-1)*eye(UserNumber))/N; %相關(guān)系數(shù)矩陣b=2*randint(UserNumber,inflength)-1; %用戶(hù)信息矩陣(隨機(jī)+1,-1矩陣)%******Generate M sequence******************coefficients=[1 0 1 0 0]; %5級(jí)左移m序列碼發(fā)生器的反饋系數(shù)mseq=mseries(coefficients); %生成31×31的m序列碼矩陣mseq=mseq(1:UserNumber,1:N);%*******************************************%**********Generate noise*******************n1=Pn*normrnd(0,1,1,inflength*N);n=zeros(UserNumber,inflength);for j=1:inflength ntemp=n1(1,((j-1)*N+1):j*N); n(:,j)=(mseq*ntemp')/N;end%******************************************* A=diag(a); y=R*A*b+n; %傳統(tǒng)單用戶(hù)檢測(cè) ydec=inv(R)*y; %線(xiàn)性解相關(guān)多用戶(hù)檢測(cè) ymmse=inv(R+sigma^2*inv(A))*y; %最小均方誤差多用戶(hù)檢測(cè) for i=1:UserNumber ylen(i)=length(find(sign(real(y(i,:)))-b(i,:))); ydeclen(i)=length(find(sign(real(ydec(i,:)))-b(i,:))); ymmselen(i)=length(find(sign(real(ymmse(i,:)))-b(i,:))); BER_y(i)=ylen(i)/inflength; BER_ydec(i)=ydeclen(i)/inflength; BER_ymmse(i)=ymmselen(i)/inflength; end snr=20*log10(a(1)/Pn); disp('信噪比為'); disp(snr); disp('誤碼個(gè)數(shù)為'); disp(ylen(k)); disp(ydeclen(k)); disp(ymmselen(k)); disp('誤碼率為'); disp( BER_y(k)); disp(BER_ydec(k)); disp(BER_ymmse(k));
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -