Reputation: 423
consider the following graphs:
All graphs represent measurements of a surface, but taken in different directions.
I would like to compute how much the blue graph(s) are shifted to the right compared to the red graph(s). Is there a built-in function in MATLAB to achieve this? If not, how else could one approximate the "phase" shift?
Upvotes: 2
Views: 882
Reputation: 7817
You can use xcorr
for a quick and dirty solution, presuming that the shifts are not too large and the sampling is equal:
[c lags] = xcorr(red,blue);
c
is the actual correlations. lags
is the shifts made to the blue
input before correlating it with red
.
Therefore, lags(c==max(c))
should tell you how much to shift blue
to get the best match with red
.
Upvotes: 3