# how to measure time delay in frequency domain

26 次查看（过去 30 天）
janan belliyappa 2017-6-5

I am new to MATlab process since i am VLSI student. plz help me in sorting out the problem i have in MATlab. How to compute delay between two signal in frequency domain? can i get full code of it ???

### 回答（1 个）

Srivardhan 2023-7-5
Hi Janan,
As per my understanding, you would like to find delay between two signals in the frequency domain.
The delay between two signals is generally done by finding the maximum in the cross-correlation of the two signals in time domain. we compute the cross-correlation of the two signals in the frequency domain by multiplying the Fourier transforms of the signals (X1 and X2) with the complex conjugate of one another. Apply the inverse Fourier transform (IFFT) to the cross-correlation result to obtain the time-domain cross-correlation.
In MALTAB, you can use “fft” and “ifft” functions to find Fourier transform and Inverse Fourier transform.
Fs = 1000; % Let us assum sample frequency
t = 0:1/Fs:1; % Converting it into time vector.
f1 = 10; % Frequency of the first signal
f2 = 15; % Frequency of the second signal
signal1 = sin(2*pi*f1*t); % First signal
signal2 = sin(2*pi*f2*t); % Second signal
% Compute the cross-correlation in the frequency domain
X1 = fft(signal1);
X2 = fft(signal2);
cross_corr = X1 .* conj(X2);
%finding the maximum in cross-correlation of two signals.(in time domain)
[~, max_index] = max(abs(ifft(cross_corr)));
delay = max_index-1; %As matlab indexing start from 1.
%delay between two signals
disp(delay);
I hope this helps!

### 类别

Help CenterFile Exchange 中查找有关 Discrete Fourier and Cosine Transforms 的更多信息

### Community Treasure Hunt

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

Start Hunting!