How do I find the phase delay between two signal?

I have two signals. Both of which I have applied the fft function to and now want to find the delay as well as a ratio of the amplitude at a certain frequency. How could I accomplish this?

 Accepted Answer

With respect to the delay, see if the finddelay (link) function will do what you want. (I believe it was introduced in R2015b. The documentation does not say specifically.)
To find the amplitudes at a specific frequency, use the fft (link) function, and compare (subtract or divide) the amplitudes at each frequency, or only your frequency-of-interest if you are only interested in one frequency. The signals must be the same length and have the same sampling frequency for this approach to work optimally.

10 Comments

Sounds good thank you! I was wondering if there was a different way to find the delay between the two waves without using the finddelay function?
My pleasure.
If you have two signals at the same frequency, in addition to comparing amplitudes using the abs function on each signal, you can use the angle function to get the phase from the real and imaginary components for each signal.
The unwrap function could be helpful, and to put the angles in 0 to 2*pi representation, this utility function works:
Angles2pi = @(a) rem(2*pi+a, 2*pi); % For ‘atan2’
for degrees:
Angles360 = @(a) rem(360+a, 360); % For ‘atan2d’
These work with the results returned by atan2 and atan2d, respectively. (According to the documentation, the angle function uses atan2.)
As always, my pleasure!
Sorry just a real quick question. What number or variable would I replace "a" with in the "Angles2pi = @(a) rem(2*pi+a, 2*pi);" function?
No apology necessary!
The argument ‘a’ is any angle in radian measure that is returned by atan2. It takes angles going from -pi to 0 to pi and produces an angle that goes from 0 to 2*pi.
okay understood. So in this case I would not replace a with a variable that I am graphing correct?
Correct.
‘Angles2pi’ is a function that you use just as you would any other function.
Example
Angles2pi = @(a) rem(2*pi+a, 2*pi); % For ‘atan2’
x = -pi/2;
Result = Angles2pi(x)
Result =
4.7124
As always, my pleasure!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!