Phase shift between two signals with cross-correlation

Good afternoon everyone. I have two time signals representing vibration measurements from two sensors and I would like to know the phase shift between them. These two signals come from a rotating device. My idea is to use cross-corelation between them so that I can find the time lag but I have a few questions:
1. Do I have to filter out the noise in the signals?
2. The signals contain a dominant harmonic and multiple of it + other harmonics. Can I still use xcorr? As I have seen many applications on the web and on this forum but all ofthem are for deterministic/pure waves signals.
If you need any additional information to answer just let me know.
Thank you

 采纳的回答

You will have to experiment with your signals to see if filtering them is necessary. If you get acceptable results without filtering, you can obviously avoid that step.
Filtering has its own problems if you are interested in the phase relationships. If you are using an IIR filter, use the filtfilt function to do the filtering, since it is phase-neutral for all filters. (It is not necessary for zero-phase FIR filters, and you can use filter with them.)
Two Signal Processing Toolbox functions that you may find helpful are finddelay (link) and alignsignals (link). (I believe these were introduced in R2015. The documentation does not say specifically.)

4 个评论

Thank you for your reply but I believe that finddelay cannot be used as it says: "X and Y need not be exact delayed copies of each other, as finddelay(X,Y) returns an estimate of the delay via cross-correlation"
In my case I know that the two signals are correlated but they are not the exact copy one of the other.
As I read the finddelay documentation, the function should work with your signals. (I do not have your data, so I cannot be certain.)
The documentation says: they ‘need not be exact delayed copies of each other’. That also seems to be the situation with your signals, as you have described them.
I would use finddelay with your signals and see if it returns a reasonable result. I mention it because it seems to be an easier way to use xcorr.
Hi! Using the command finddelay I get the same result as looking at the time lag of the maximum covariance (using xcorr). What I do not understand is the meaning of this values. Since my signal is a summation of multiple waves, is that value some sort of avarage delay?
I am not certain. For a full explanation of what finddelay does and how it works, I refer you to the documentation section on Algorithms (link).

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by