Find a portion of a signal using dtw ?
19 次查看(过去 30 天)
显示 更早的评论
I have the two attached signals and I want to know if "ref" is included somehow (time warping could happen) inside "det" signal.
Figure 1 show ref and det signals:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1737931/image.png)
As you can see ref "can fit" inside det (ref is similar to det(1:100) aprox ) so I try to adjust them normalizing signals and using dtw:
refn=ref/max(ref);
detn=det/max(det);
[~, ix ,iy]= dtw(detn,refn);
figure;plot(refn(iy));hold on;plot(detn(ix));
max(normxcorr2(refn(iy),detn(ix)))
Obtaining:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1737936/image.png)
I would love to be able to dtw adjust ref signal over det with the nedd of both signal be the same size so the adjust could be better. For example in this case I could have the signals between x=57:204 and get a better correlation (0.99) of both signals:
x=detn(ix);
y=refn(iy);
max(normxcorr2(x(57:204),y(57:204)))
But I'm missing the first part of ref signal (which could fit quita well) and also some samples at the end because dtw always thinks that both signals have to be the same size but I'm looking also for the possibility of being just a fragment of the other.
Any clue on how to get this adjustment of signals when one can be a portion of the other?
All the best
7 个评论
Umar
2024-7-23
Hi David,
To keep signal1 unmodified (no warping), you should set the constraint to 0 in the warpPath matrix. By setting warpPath(i, 1) = max(1, i-0) and warpPath(i, 2) = min(n, i+constraint), it will make sure no warping for signal1.
Now, to obtain indexes (ix, iy) from the D matrix in DTW function, you can find the optimal warping path by backtracking through the accumulated cost matrix D. The indexes can be extracted by following the path with the lowest accumulated cost. It sounds like you are making progress.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!