pn_1.m

来自「频谱感知 多用户合作 能量检测 伪随机序列」· M 代码 · 共 35 行

M
35
字号

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%this is a function for generating pn sequences%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function gold_seq=PN_1(connections1,connections2)
echo on 
%connections1=[1 0 1 0 0 ];
%connections2=[1 1 1 0 1 ];
sequence1=ss_mlsrs(connections1);
sequence2=ss_mlsrs(connections2);
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;
    echo off;
end;
echo on;
max_cross_corr=0;
for i=1:L-1
    for j=i+1:L
        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
        echo off;
        end 
    end 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



⌨️ 快捷键说明

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