Finding delay b/w two signals using gccphat

3 views (last 30 days)
nauman
nauman on 5 Feb 2023
Commented: Mathieu NOE on 28 Jun 2023
Hi all
I am simulating signals on two hydrophones H1 and H2 of linear array which are at a distance 'd' from each other. The geometry is shown below:
Assuming Plane Wave assumption, there will be some delay b/w signals arriving at H1 and H2 assuming zero noise and pure sinusoidal signals. After simulating the signals with delays, I am trying to calculate back the delay using MATLAB 'gccphat' function, but its output does not match with the delay simulated in signals? MATLAB code is given below:
clc
clear
close all
%%%%=======================================================================
%%%%============================General Parameters=========================
%%%%=======================================================================
total_sens=2;
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
c=1500;%speed of sound
%%%%=======================================================================
%%%%=====================DA PRA Array Parameters===========================
%%%%=======================================================================
D=15;%separation b/w sensors in m
Target_theta=40;%Source angle in deg
delay_=D*sind(Target_theta)/c
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')
tau12=gccphat(H1,H2,samp_f)
The simulated delay_ is approx. 0.0064s whereas delay calculated by 'gccphat is 0s?.
Kindly help me in this regard. Thanks

Answers (1)

Mathieu NOE
Mathieu NOE on 6 Mar 2023
Edited: Mathieu NOE on 6 Mar 2023
hello
I think I can get the correct result with the regular xcorr function (I have not the toolbox for gccphat function)
but I needed to create more "realistic" signals. With you definition, both signals are sine stationnary signals without any amplitude shape that also includes the delay
So I opted for a bell (gaussian) shaped amplitude modulation. and you will see that xcorr gives the correct value in that case
clc
clearvars
close all
%%%%=======================================================================
%%%%============================General Parameters=========================
%%%%=======================================================================
total_sens=2;
fo=8500;%frequency in Hz
samp_f=30*51.2e3;%Sampling frequency
samp_t=1/samp_f;
chunk_size=163840;
% chunk_size=20000;
total_chunks=1;
chunk_time=chunk_size/samp_f;
chunk_t=samp_t*(0:(chunk_size-1));%time vector calculated
c=1500;%speed of sound
%%%%=======================================================================
%%%%=====================DA PRA Array Parameters===========================
%%%%=======================================================================
D=15;%separation b/w sensors in m
Target_theta=40;%Source angle in deg
delay_=D*sind(Target_theta)/c % in seconds
delay_ = 0.0064
delay_samples = round(delay_*samp_f); % in samples
% your signals definition
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')
% compute delay with xcorr
[c_a, lag_a] = xcorr(H1,H2);
[~, i_a] = max(c_a);
tau_xcorr = lag_a(i_a)/samp_f % lag in seconds (incorrect)
tau_xcorr = -4.2969e-05
% tau_gccphat = gccphat(H1,H2,samp_f)
% % my signals definition
t0 = round(chunk_size/2)/samp_f; % create a bell shaped signal with a peak of the bell located mid x range
H1(1:chunk_size,1)=exp(-(chunk_t-t0).^2/4e-4).*sin(2*pi*fo*(chunk_t))+0*randn(1,chunk_size);%Sensor H1 signal
H2(1:chunk_size,1)= exp(-(chunk_t+delay_-t0).^2/4e-4).*sin(2*pi*fo*(chunk_t+delay_))+0*randn(1,chunk_size);%Sensor H2 signal
figure,plot(H1),hold on,plot(H2,'r')
% compute delay with xcorr
[c_a, lag_a] = xcorr(H1,H2);
[~, i_a] = max(c_a);
tau_xcorr = lag_a(i_a)/samp_f % lag in seconds (correct)
tau_xcorr = 0.0065
% tau_gccphat = gccphat(H1,H2,samp_f)
  1 Comment
Mathieu NOE
Mathieu NOE on 28 Jun 2023
Hello
Problem solved ?
would you mind accepting my answer ? thanks !

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!