dtw1m
Pure m-file implementation of DTW (dynamic time warping) with local paths of 27, 45, and 63 degrees
Contents
Syntax
- minDist = dtw1m(vec1, vec2)
- minDist = dtw1m(vec1, vec2, beginCorner, endCorner)
- minDist = dtw1m(vec1, vec2, beginCorner, endCorner, plotOpt)
- minDist = dtw1m(vec1, vec2, beginCorner, endCorner, plotOpt, distanceBound)
- [minDist, dtwPath, dtwTable] = dtw1m(...)
Description
dtw1m(vec1, vec2, beginCorner, endCorner, plotOpt, distanceBound) returns the DTW distance between vec1 and vec2, assuming a local path constrains of 27, 45, and 63 degrees.
- vec1: testing vector
- vec2: reference vector
- beginCorner: 1 for anchored beginning
- endCorner: 1 for anchored ending
- plotOpt: 1 for plotting the DTW path
- distanceBound: distance bound for stop the computation. (Stop the computation immediately if the accumulated DTW distance is larger than this distance bound.)
[minDist, dtwPath, dtwTable] = dtw1m(...) also return two extra results:
- dtwPath: optimal path of DTW (Its size is 2xk, where k is the path length.)
- dtwTable: DTW table
Note that this function is a pure m-file implementation which is slow but easy to customize.
Example
vec1=[71 73 75 80 80 80 78 76 75 73 71 71 71 73 75 76 76 68 76 76 75 73 71 70 70 69 68 68 72 74 78 79 80 80 78]; vec2=[69 69 73 75 79 80 79 78 76 73 72 71 70 70 69 69 69 71 73 75 76 76 76 76 76 75 73 71 70 70 71 73 75 80 80 80 78]; [minDist, dtwPath, dtwTable] = dtw1m(vec1, vec2); dtwPathPlot(vec1, vec2, dtwPath);
![](dtw1m_help_01.png)
See Also
dtwPathPlot, dtwBridgePlot, dtw1, dtw2, dtw3.