Calculate shifts/translation between two curves

40 ビュー (過去 30 日間)
Angelavtc 2020 年 10 月 21 日
コメント済み: Star Strider 2020 年 10 月 23 日
Dear all,
Is there a way to determine if the blue curve has shifted from the purple curve? (see graph). As you can see, before the black line the blue curve shifts to the right of the purple one and after the black line the curve shifts to the left. Is there a way to do an analysis that tells us this? Maybe a separate analysis of regions that tells us the shift of the curve? I have seen that the xcorr command is used to measure displacements, but in a generalized way. When I apply it to this case, the maximum lags are zero.
Thanks in advance!


Star Strider
Star Strider 2020 年 10 月 21 日
The blue curve is not ‘shifting’. It has a different scale with respect to the independent variable than the purple curve. The correct way to characterise it would be to compare the characteristics of the two curves.
For example —
x = linspace(-100, 100);
yb = 1./(1+exp(-0.1*x));
yp = 1./(1+exp(-0.05*x));
ratio = mean(gradient(yb)./gradient(x)) / mean(gradient(yp)./gradient(x));
plot(x, yb, '-b')
hold on
plot(x, yp, '-m')
hold off
Here, the ‘ratio’ metric compares the means of the numeric derivatives (calculated by the the gradient function) to characterise them. I am certain there are more appropriate metrics for your curves, however something like that would likely be more appropriate than measuring a ‘shift’ that is actually not a shift.
  5 件のコメント
Star Strider
Star Strider 2020 年 10 月 23 日
As always, my pleasure!
The problem is that there does not appear to be much difference between the signals, at least with respect to the indices. The finddelay funciton assumes that one signal is zero-padded with respect to the other, and the related functions also assume a common independent variable vector. Also, the independent variable vectors are not only not common, they also have different sampling intervals and ranges.
That is most evident with:
[S1,L1] = bounds(x1);
[S2,L2] = bounds(x2);
range_x1 = L1-S1
range_x2 = L2-S2
range_x1 =
range_x2 =
even though they have the same number of elements(30000 each).
so likely the best you can hope for is:
delay = min(x2)-min(x1)
delay =
assuming that the units of the independent variables are the same (for example, seconds).
One function you can experiment with is dtw that measures the distance between signals using ‘dynamic time warping’:
[disty,ix,iy] = dtw(y1,y2);
I defer to you to interpret the results, sdince I do not know what your signals are.


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by