You can use generalized cross-correlation to estimate the time difference of
arrival (TDOA) of a signal at two different sensors.

To estimate TDOA, find the locations of the peak of the cross-correlation function between
the received signal at one sensor and the received signal at a second sensor. The peak of
the cross-correlation function corresponds to the time delay. Both the `phased.GCCEstimator`

and `phased.TDOAEstimator`

System objects compute correlation peaks using the
Generalized Cross-Correlation with Phase-Transformation (GCC-PHAT) algorithm. Peak locations
are restricted to multiples of the sample interval which is the inverse of the signal sample
rate. You can specify the signal sample rate by the `SampleRate`

property
which is common to both System objects.

To compute the time delay between two signals,
*x*_{1}*(t)* and
*x*_{2}*(t)*, start with their
time-domain representations in the presence of noise:

where *n*_{1}(t) and
*n*_{2}(t) are the noises added to each signal.
*D* is the time-delay.

In the frequency domain, the signals are represented as

Define the cross-correlation function between two signals in the time domain and in the
frequency domain.

To identify the time delay, locate the peak of the cross-correlation
function *τ*_{max}. When the signal-to-noise ratio
(SNR) is large, the correlation peak *τ*_{max}
corresponds to the actual time delay *D*. When the correlation function is
more sharply peaked, performance improves. You can sharpen the cross correlation peak by
using a weighting function that whitens the input signals. This technique is called
*generalized cross-correlation* (GCC). One particular weighting
function normalizes the signal spectral density with the spectrum magnitude, leading to the
*generalized cross-correlation phase transform* method
(*GCC-PHAT*). The Generalized Cross-Correlation function with Phase
Transform (GCC-PHAT) at lag *τ* is defined as

where *δ* is the Dirac-delta function which is non-zero
at *D=τ*, which is the time-difference of arrival (TDOA). Typically, the
lag is calculated in samples, so to convert that to seconds, divide by the sampling rate.
You can estimate the time delay by finding the time lag that maximizes the cross-correlation
between the two signals.

From the TDOA, you can estimate the broadside arrival angle of the plane wave with respect to
the line connecting the two sensors. For two sensors separated by distance
*L*, the broadside arrival angle, Broadside Angles, is related to the time lag by

where *c* is the propagation speed in the medium.

If you use just one sensor pair, you can only estimate the broadside angle of arrival.
However, if you use multiple pairs of non-collinear sensors, for example, in a URA, you can
estimate the arrival azimuth and elevation angles of the plane wave using least-square
estimation. For *N* sensors, you can write the delay time
*τ*_{kj} of a signal arriving at the
*k*^{th} sensor with respect to the
*j*^{th} sensor by

where *u* is the unit propagation vector of the plane
wave. The angles α and θ are the azimuth and elevation angles of the propagation vector. All
angles and vectors are defined with respect to the local axes. You can solve the first
equation using least-squares to yield the three components of the unit propagation vector.
Then, you can solve the second equation for the azimuth and elevation angles.