0
$\begingroup$

I am generating two signals of same frequency, i introduce a fixed delay in one of the signal and then try to find out the simulated delay using MATLAB 'gccphat' and 'finddelay' functions, but not able to measure correct delay. MATLAB Code script is given below:

    clc
clear
close all


%%%%=======================================================================
%%%%============================General Parameters=========================
%%%%=======================================================================
fo=8500;%frequency in Hz
samp_f=30*51.2e3;%Sampling frequency 
samp_t=1/samp_f;
chunk_size=163840;
total_chunks=1;
chunk_time=chunk_size/samp_f;
chunk_t=0:samp_t:(samp_t*(chunk_size-1));%time vector calculated

delay_=0.0064;

H1(1:chunk_size,1)=sin(2*pi*fo*(chunk_t))+0*randn(1,chunk_size);%Sensor H1 signal
H2(1:chunk_size,1)=sin(2*pi*fo*(chunk_t+delay_))+0*randn(1,chunk_size);%Sensor H2 signal
figure,plot(H1(1:2000)),hold on,plot(H2(1:2000),'r')

format long
tau_a=gccphat(H1,H2,samp_f)
tau_b = finddelay(H1, H2) / samp_f

Output:
tau_a = 0
tau_b = 1.171875000000000e-05

Can any one kindly point out where i am doing wrong with such simple task? As per my understanding, both outputs should match with the delay i.e. 0.0064s? Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

The problem is ill defined for two sine waves (or for any periodic signal).

If you delay a sine wave of period $T$ by a full period you get the exact sine wave again. So you can't tell whether the delay between two identical sine waves is 0, $-T$ $27T$ or any multiple of $T$

That's why the cross correlation of two sine waves is also a sine wave with an infinite amount of maxima and minima. The answer "what is the delay between these two sine waves" has infinitely many answers.

If you blindly throw an algorithm at this problem the answer will mostly depend on boundary conditions and minute details of how the algorithm is implemented.

$\endgroup$
1
  • $\begingroup$ I am trying to simulate 8.5 KHz signal coming from an angle 45 deg (measured from broadside) on two hydrophones H1 and H2 of linear array which are at a distance 'd=15m' from each other. The delay calculated b/w two signals is approx.0.0064 sec using delay_=d*sin(theta)/c formula where c=1500m/s. I need to measure angle of arrival of signal by measuring delay b/w two signals using cross-correlation method. How should i proceed in this case? $\endgroup$ Commented Feb 12, 2023 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.