Cody

# Problem 43478. Calculate the dynamic time warping similarity

Solution 1099542

Submitted on 6 Jan 2017 by John Wirzburger
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x1 = [0 0 1 2 3 4 3 2 1 0 0 1 0]; x2 = [0 1 2 3 6 3 3 2 1 0 0 0 1 0]; y = 2; assert(isequal(dtw_similarity(x1,x2),y));

2   Pass
x1 = [0 0 1 2 3 4 3 2 1 0 0 1 0]; x2 = [0 1 2 3 4 5 4 4 2 1 0 0 1 2 1 0]; y = 3; assert(isequal(dtw_similarity(x1,x2),y));

3   Pass
x1 = [0.47,0.84,0.99,0.90,0.59,0.14,-0.35,-0.75,-0.97,-0.95,-0.70,-0.27,... 0.21,0.65,0.93,0.98,0.79,0.41,-0.07,-0.54]; x2 = [0.14,0.48,1.06,0.95,0.78,0.79,0.16,-0.29,-0.38,-1.10,-0.86,-0.71,... -0.64,-0.15,0.01,0.39,0.92,1.14,1.44,0.53,0.33,-0.16,-0.93,-0.93,-1.35]; y = 4.88; assert(abs(dtw_similarity(x1,x2)-y)<1E-10);

4   Pass
s = zeros(1,100); for i=1:100, x1 = linspace(1,10,10+i); x2 = linspace(1,10,12+i)+0.1; s(i) = dtw_similarity(x1,x2); end y = [2.8000,2.7692,2.6857,2.6923,2.6714,2.6471,2.6500,2.6192,2.6000,... 2.5910,2.5909,2.5665,2.5545,2.5478,2.5500,2.5333,2.5231,2.5172,... 2.5143,2.5028,2.5000,2.4962,2.4838,2.4857,2.4824,2.4795,2.4789,... 2.4703,2.4684,2.4653,2.4643,2.4606,2.4571,2.4558,2.4522,2.4511,... 2.4522,2.4549,2.4575,2.4600,2.4662,2.4713,2.4808,2.4889,2.4976,... 2.5081,2.5187,2.5293,2.5276,2.5257,2.5258,2.5239,2.5226,2.5220,... 2.5222,2.5195,2.5182,2.5174,2.5176,2.5156,2.5143,2.5137,2.5135,... 2.5115,2.5108,2.5099,2.5081,2.5087,2.5077,2.5068,2.5073,2.5056,... 2.5049,2.5044,2.5030,2.5028,2.5023,2.5015,2.5000,2.5003,2.5000,... 2.4992,2.4981,2.4983,2.4979,2.4975,2.4969,2.4964,2.4959,2.4953,... 2.4953,2.4947,2.4941,2.4936,2.4933,2.4928,2.4925,2.4922,2.4909,... 2.4914]; assert(norm(s-y)<3E-4);

### Community Treasure Hunt

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

Start Hunting!