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

📄 get_gold.m

📁 CDMA多用户检测中传统检测器
💻 M
字号:
function [gold_seq]=get_gold(connections1,connections2)
sequence1=ss_mlsrs(connections1);
sequence2=ss_mlsrs(connections2);
% cyclically shift the second sequence and add it to the first one
L=2^length(connections1)-1;;
for shift_amount=0:L-1,
  temp=[sequence2(shift_amount+1:L) sequence2(1:shift_amount)];
  gold_seq(shift_amount+1,:)=(sequence1+temp) - floor((sequence1+temp)./2).*2;
end;
% find the max value of the cross correlation for these sequences
max_cross_corr=0;
for i=1:L-1, 
  for j=i+1:L, 
    % equivalent sequences 
      c1=2*gold_seq(i,:)-1; 
      c2=2*gold_seq(j,:)-1; 
     for m=0:L-1, 
         shifted_c2=[c2(m+1:L) c2(1:m)]; 
         corr=abs(sum(c1.*shifted_c2)); 
        if (corr>max_cross_corr), 
           max_cross_corr=corr; 
       end; 
    end; 
  end; 
end;
for i=1:L,
    for j=1:L,
        if  (gold_seq(i,j)==0),
            gold_seq(i,j)=-1;
        else
            gold_seq(i,j)=1;
        end;
        gold_seq(i,j)=gold_seq(i,j);
    end;    
end;            

%Sub function ss_mlsrs
function [seq]=ss_mlsrs(connections);
% [seq]=ss_mlsrs(connections)
%		SS_MLSRS  generates the maximal length shift register sequence when the
%   		shift register connections are given as input to the function. A "zero"
%   		means not connected, whereas a "one" represents a connection. 
m=length(connections);		
L=2^m-1;				% length of the shift register sequence requested
registers=[zeros(1,m-1) 1];		% initial register contents
seq(1)=registers(m);			% first element of the sequence
for i=2:L,
   new_reg_cont(1)=connections(1)*seq(i-1);
   for j=2:m,
     new_reg_cont(j)=registers(j-1)+connections(j)*seq(i-1);
   end;
   registers=new_reg_cont;		% current register contents
   seq(i)=registers(m);			% the next element of the sequence
end;

⌨️ 快捷键说明

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