Вопрос

consider the following graphs:

enter image description here

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top