changing the reference sequence in DTW
3 views (last 30 days)
Show older comments
Hello everyone,
I wanted to use Dynamic Time Warping to align one sequence with respect to the reference one (the time series are stretched or compressed). But, when using the command “dtw” in MATLAB, after finding the optimal path, both time series are stretched. Let me give you an example: the reference is x1 = [1 1 1 2 2 4 4 2 1 1 ], with 10 points (length=10), and the other sequence is x2 = [1 2 2 3 3 2 2 1 1], with 9 points. In addition, the warping path has 11 points, therefore, when MATLAB plot the aligning data show me two plots (in one figure) with 11 points.
![1.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268081/1.jpeg)
But, I don’t want my reference signal to stretch. I would really appreciate it if you help me to align x2 with respect to the reference signal without changing the reference signal. It is worth to note that as the procedure of DTW shows, the boundaries of warping path is “max(length(x1) and length(x2))<points of w< length(x1) + length(x2)-1”.
![2.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268082/2.jpeg)
But as I have studied some papers, in all their figures the reference signal did not change (Please see figures below, the first one is related to the time series before alignment and the second one is related to the time series after alignment). as it can be seen the number of points are 596 in both figures.
![3.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268083/3.jpeg)
![4.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268084/4.jpeg)
Unfortunately, I confused. Does DTW change both sequences? If the answer is “No, it won’t change the reference one”, then why MATLAB software change it; and what does the warping path boundaries tell us; and how can I overlay the other sequence on the non-changed reference?
If the answer is “Yes”, why all the papers show us the result of DTW without changing the reference one. (If you need, I can introduce you some papers.)
Thanks guys. Every help will appreciate.
Yours sincerely,
1 Comment
Jo
on 12 Jul 2021
Hi, I would be really interested if you found a way to not change your reference signal. I know that your post is old but may be you found out the solution.....thanks !
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!