File Exchange

image thumbnail

Constrained Dynamic Time Warping Distance Measure

version 1.0 (6.78 KB) by

This MEX function computes the constrained dynamic time warping distance between two time series.

7 Ratings



No License

This is the C source code for a Matlab executable (MEX) function named cdtw_dist(). This function returns the Constrained (by Sakoe-Chiba band) Dynamic Time Warping distance between two time series. This function has 3 input parameters and 1 return value: "distance = cdtw_dist(query_vector, candidate_vector, radius);". The distance value is the square root of the minimum sum of squared differences divided by the number of comparisons. If radius == Inf, distance is the unconstrained dynamic time warping distance. Both the time and space complexity of this function are O(mn), where m is the length of the query_vector and n is the length of the candidate_vector. This MEX function was tested using Matlab (R14SP1) for Windows with Matlab's Lcc C (v2.4). These Matlab commands were used to compile this function: "mex -setup; mex cdtw_dist.c;".

Comments and Ratings (12)


 mex cdtw_dist.c
cdtw_dist.c(75) : warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
cdtw_dist.c(76) : warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
cdtw_dist.c(94) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(95) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(100) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(101) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(106) : warning C4244: “=”: 从“double”转换到“int”,可能丢失数据
cdtw_dist.c(107) : warning C4244: “=”: 从“double”转换到“int”,可能丢失数据
cdtw_dist.c(112) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(113) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(165) : error C2065: “DBL_MAX”: 未声明的标识符
cdtw_dist.c(166) : error C2065: “DBL_MAX”: 未声明的标识符
  E:\MATLAB~1\BIN\MEX.PL: Error: Compile of 'cdtw_dist.c' failed.
Error using mex (line 206)
Unable to complete successfully.
 how to solve it,help!!!

I can use this function to calculate the distance of a matrix? How can I do this?

lu li

lu li (view profile)

very good thanks



Doug (view profile)

DBL_MX is not a variable it is a constant. It documents the maximum size of a DBL word on the machine where you compile the C code.


Nandha (view profile)

may I ask what is DBL_MAX variable for ?


Ahmed (view profile)

# include "float.h"

i add the above line because 'DBL_MAX' is defined in it. The algorithm work without erros. good work


Ahmed (view profile)

who can solve this problem : variable 'DBL_MAX' is not definded in the file

Ahmed Bderhman

I think this is a good working and had help me more.

I have this question: i like to change euclidean distance{d=(repmat(Test',1,N)-repmat(Ref,M,1)).^2;} with mahalanobis distance is it possipole? if yes how can i do that?

because i like to test the efficiency of my system when i use euclidean distance and when i used mahalnobis distance.

viram mishra

xu ning

Good Work!But the variable 'DBL_MAX' is not definded in the file.

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Inspired by: Dynamic Time Warping

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video