⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lmsreceiver.m

📁 CDMA多用户检测中传统检测器
💻 M
字号:
%product received vector 
function [p]=lmsreceiver(snr_in_dB,u)
Lc=31;                  %Lc is frame size
snr=10^(snr_in_dB/10);
sgma=1;                  % noise standard deviation is fixed 
Eb=2*sgma^2*snr;         % signal level required to achieve the given 
                         % signal to noise ratio 
E_chip=Eb/Lc;            % energy per chip 
A=[sqrt(10*Eb),sqrt(10*Eb),sqrt(10*Eb),sqrt(10*Eb),10*sqrt(Eb)];
N=10000;                  % number of bits transmitted                   
K=length(A);             % number of users
x=zeros(31,1);
num_of_err=0;
connections1=[1 0 1 0 0];
connections2=[1 1 1 0 1];
gold_seq=get_gold(connections1,connections2);
  % the gold sequence of user1 
user1code=(1/sqrt(Lc))*gold_seq(:,31);
c=user1code;
% The generation of the data, noise, interference, decoding process and error 
% counting is performed all together in order to decrease the run time of
% the program. This is accomplished by avoiding very large sized vectors. 
for i=1:N, 
  % generate the next data bit 
    temp=rand;  
    if (temp<0.5), 
       data=-1; 
   else 
       data=1; 
   end;
  % repeat it Lc times, i.e. divide it into chips
  % gold sequence for the duration of the bit is generated next 
  
   % the transmitted signal is 
  trans_sig=sqrt(Eb)*data*user1code; 
  % AWGN with variance sgma^2 
  noise=sgma*randn(Lc,1); 
  % interference user data is dat
  inter_sig=zeros(31,1);
  for k=1:K,
      temp1=rand;	
          if (temp1<0.5),
              dat=-1;
         else
              dat=1;
         end;
     inter_sig=inter_sig+A(k)*dat*(1/sqrt(Lc))*gold_seq(:,k);
  end;
  % received signal 
  rec_sig=trans_sig+noise+inter_sig; 
  %making detect
  Zmf=dot(rec_sig,user1code);
  c1=user1code+x;
  Z=dot(rec_sig,c1);
  x=x-u.*Z*(rec_sig-Zmf*user1code);
  c=user1code+x;
   % making decision
  rec_data=dot(rec_sig,c);
  decision_variable=sign(rec_data); 
  if (decision_variable<=0),
    decision=-1;
  else
    decision=1;
  end;
  % if it is an error, increment the error counter
  if (decision~=data),
    num_of_err=num_of_err+1;
  end;
end;
p=num_of_err/N; 
  
  
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -