資源簡介
用matlab實現了DTW算法,已經經過了測試
代碼片段和文件信息
function?dist=dtw_func(compare_to_this_objectunknow_object)
????format?long?e;
????m=length(compare_to_this_object);
????n=length(unknow_object);
????c?=?ones(mn);
????
????for?i?=?1:m?????%可以看出這里在算法中把a豎著
????????for?j?=?1:n
????????????tmp=?(compare_to_this_object(i)-unknow_object(j))^2;??????%歐式距離???
????????????if?j?==?1&&?i?==?1
????????????????c(ij)?=?tmp;???%如果是c(11),則不用包含累積距離,直接用歐氏距離
????????????elseif?j>1
????????????????c(ij)?=?c(ij-1)?+?tmp;????%其他的考慮累積距離
???
評論
共有 條評論