sanzhxl 发表于 2009-7-23 09:38

如何确定FFT时延时间?

问题描述:
情况1:信号1在信号2之前,可准确定位时延,即程序中Nn<N1,可准确求出时延结果为N1-Nn
情况2:信号1在信号2之后,时延应是负值a,结果为正值,是信号长度L与真正时延a之和(在程序中为Nn>N1,真正时延结果为 N1 - Nn,但程序结果为L+N1—Nn)。若单纯的减去信号长度L,则当信号2在信号1之后,且时延为L+a时,这两种情况会出现混绕。
请问各位大侠,如何解决这种问题。下面是程序部分。
%% 广义自相关法时延估计函数可行性测试部分
    clc; clear all ;close all;
    wn =rand(10240,1);
    phi = ;
    signal = 0;
    for i = 1:5
      signal = signal + 1* sin(2*i*pi*phi);%.*exp(-(2*i*pi*phi));
    end
    signal = signal/max(abs(signal));%信号归一化
    temp = zeros(10240,1);
    Nn = 1;
    temp (Nn:length(signal)+Nn-1)= signal;
    signal1 = wn +temp;
%   plot(signal1);hold on;

    N1 = 1001 ;
    temp1 = zeros(10240,1);
    temp1(N1:N1-1+length(signal))= signal;
    wn1 =rand(10240,1);
    signal2 = wn1 +temp1;
    plot(signal2,'r');
%%
= size(signal1);
D= GCC(signal1,signal2,'scot');
msgbox(['d = ',num2str(N1-Nn)'D1= ',num2str(D)])%,'D2= ',num2str(D2)]);

子函数 GCC.m
function = GCC(Sig1,Sig2,m,Fs,frame,N)


if nargin<2
    error('Wrong number of input arguments');
elseif nargin == 2
    m = 'roth';
end


Pxx = (abs(fft(Sig1))).^2;
Pyy = (abs(fft(Sig2))).^2;
Pxy = conj(fft(Sig1)).*fft(Sig2);
N = size(Pxy,1);


% define pre-whitening filter
switch lower(m)
    case 'unfiltered'
      % Unfiltered Cross-Correlation (UCC)
      % -----------------------------------------------------------------
      % this processor doesn't filter the cross-power applying a sort of
      % time cross-correlation.
      W = ones(N,1);

    case 'roth'
      % Roth filter
      % -----------------------------------------------------------------
      % this processor suppress frequency regions where the noise is
      % large than signals.
      if size(Pxx)~=size(Pxy)
            error('Roth filter: power spectra size must be the same');
      end
      W = ones(N,1);
      nonzero = find(Pxx(:,k));
      W(nonzero,k) = 1 ./ Pxx(nonzero,k);


    case 'scot'
      % Smoothed Coherence Transform (SCOT)
      % -----------------------------------------------------------------
      % this processor exhibits the same spreading as the Roth processor.
      if size(Pxx)~=size(Pyy) | size(Pxx)~=size(Pxy) | size(Pyy)~=size(Pxy)
            error('SCOT filter: power spectra size must be the same');
      end
      W = ones(N,1);
      W_Den = (Pxx .* Pyy) .^ 0.5;
      nonzero = find(W_Den(:,k));
      W(nonzero,k) = 1 ./ W_Den(nonzero,k);
      
   
    otherwise error('Method not defined...');
end

% apply the filter
R = Pxy .* W;

% estimate the generalized cross-correlation (GCC)
G = abs(ifft(R));

D = find(G==max(G),1,'first') ;

[ 本帖最后由 sanzhxl 于 2009-7-23 09:46 编辑 ]
页: [1]
查看完整版本: 如何确定FFT时延时间?