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

📄 detection_analysize_r_pd.m

📁 包括载波跟踪和伪码相位跟踪
💻 M
字号:
%%检测程序
function [snr,acq_flag,Correl_Peak_location]=Detection_Analysize_R_pd(Bandwidth,fd,f0,SNR,sigma_n,code_cycle,times_estimate,inputcode,T_interp,T,fd_estimate,Ts,fi,N,A1,B,M,fs,IntervalOfFreq,Code_native_fft_conj,dot_insert,delay_time,coef,coef_mod,EmulateIndex);

acq_flag=0;
for timeofestimate=1:times_estimate                                                  %搜索37个频点开始
    fd_estimate=fd_estimate+(-1)^timeofestimate*(timeofestimate-1)*IntervalOfFreq;   %估计多普勒频率
   fd_estimate = 1000;
    %%%%唐检测参数复位
    tong_k=B;
    tong_k_last=0;
    timeOfdetection=1;
    
    while(tong_k~=0&&tong_k~=A1)
        for timesOfaccumu=1:M %加入M次非相干积累
            EmulateIndex=EmulateIndex+1;
            %%%%产生中频信号
            [signal,signal_noise]=SignalGenerator(EmulateIndex,inputcode,fs,Ts,fi,delay_time,fd,SNR,Bandwidth,code_cycle,sigma_n,f0,N);
%             figure(1)
%             plot(abs(fft(signal)));
            IF_signal(1:N)=signal(1:N);
            IF_signal_noise(1:N)=signal_noise(1:N);
%             figure(21);
%             plot(IF_signal);
%             figure(22);
%             plot(IF_signal_noise);
            %%%%进行下变频
            [NCO_I_Quanti,NCO_Q_Quanti]=Nco_gen(Ts,fi,fd_estimate,N);                        %NCO产生        
            Rece_Signal_Quan_down_I = IF_signal(1:N).* NCO_I_Quanti;
            Rece_Signal_Quan_down_Q = IF_signal(1:N).* NCO_Q_Quanti;
            Rece_Signal_Quan_down_I_noise=IF_signal_noise.*NCO_I_Quanti;
            Rece_Signal_Quan_down_Q_noise=IF_signal_noise.*NCO_Q_Quanti;
            
         
            %%%%经过低通滤波器,截止频率为1.023MHz
            [signal_I,signal_Q,signal_I_noise,signal_Q_noise]=LP_filter(N,M,code_cycle,fs,Rece_Signal_Quan_down_I,Rece_Signal_Quan_down_Q,Rece_Signal_Quan_down_I_noise,Rece_Signal_Quan_down_Q_noise,EmulateIndex);       %进过低通滤波器
%             figure(2)
%             plot(abs(fft(signal_I)));
%             %%%%采用线性内插
            for index_new=1:dot_insert
                index_previous=floor((index_new-1)*T_interp/Ts)+1;                                                 %产生内插抽取所需的原序列索引值
                Rece_Signal_down_I_1(index_new)=signal_I(index_previous)+round(((signal_I(index_previous+1)-signal_I(index_previous)))*mod(((index_new-1)*coef),coef_mod)/coef_mod);
                Rece_Signal_down_Q_1(index_new)=signal_Q(index_previous)+round(((signal_Q(index_previous+1)-signal_Q(index_previous)))*mod(((index_new-1)*coef),coef_mod)/coef_mod);
                Signal_Input(index_new)=Rece_Signal_down_I_1(index_new)-sqrt(-1)*Rece_Signal_down_Q_1(index_new);
            end%%内插完成 

            signal_fft=fft(Signal_Input,dot_insert);
            %%%%与本地伪码进行相关
            Z_spectrom=signal_fft.*Code_native_fft_conj;
            Z_last=ifft(Z_spectrom);
            Z_last_abs=abs(Z_last);
            Z_last_square=Z_last_abs.^2;
            Z_last_square_M(((timesOfaccumu-1)*dot_insert+1):(timesOfaccumu*dot_insert)) = Z_last_square;
        end  %非相干积累完毕


        Z= reshape(Z_last_square_M(1:M*dot_insert),dot_insert,M);   % 生成(4096*M)阶的矩阵  
        Z_r = Z';                                                   % 将(4096*5)阶的矩阵转置为(M*4096)阶的矩阵  
        Result_Sum(timeOfdetection,:) = sum(Z_r,1);                 % 进行M次非相参积累


        Correl_Peak = max(Result_Sum(timeOfdetection,:));           %检测峰值
        Correl_Peak_location(timeofestimate,timeOfdetection) = find(Result_Sum(timeOfdetection,:) == Correl_Peak,1,'first');     % 结果为(Detection_Times*1)维矩阵,查找第一个最大值 
        snr(timeofestimate,timeOfdetection) =Correl_Peak/mean(Result_Sum(timeOfdetection,:));                                    %计算峰均比,作为门限判决   

        %%%门限判决    
            switch tong_k   
                case 1
                    if(tong_k_last~=2)
                        if (snr(timeofestimate,timeOfdetection)>4.5)            
                            tong_k=tong_k+1;
                        else
                            tong_k=tong_k-1;
                        end
                    elseif (snr(timeofestimate,timeOfdetection) >4.5&&abs(Correl_Peak_location(timeofestimate,timeOfdetection)-Correl_Peak_location(timeofestimate,1))<=4)              % 门限范围4.5dB~6.5dB,每0.1dB步进
                            tong_k_last=tong_k;
                            tong_k=tong_k+1;
                    else
                            tong_k_last=tong_k;
                            tong_k=tong_k-1;
                    end
                 otherwise
                        tong_k_last=tong_k;
                        if (snr(timeofestimate,timeOfdetection) >4.5&&abs(Correl_Peak_location(timeofestimate,timeOfdetection)-Correl_Peak_location(timeofestimate,1))<=4)              % 门限范围4.5dB~6.5dB,每0.1dB步进
                            tong_k=tong_k+1;
                        else
                            tong_k=tong_k-1;
                        end
              end

            if(tong_k==5)
                disp('信号存在')
                acq_flag=1;
                break;
            else if(tong_k==0)
                disp('信号不存在')
                end;
            end;
            timeOfdetection=timeOfdetection+1;
    end
%         if acq_flag==1
%             break;
%         end;
end  %搜索37个频点完毕

⌨️ 快捷键说明

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