changing the reference sequence in DTW

4 views (last 30 days)
Mahdi Khosravi
Mahdi Khosravi on 24 Jan 2020
Commented: Jo on 12 Jul 2021
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.jpgn the x
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
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
4.JPG
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
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 !

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!