文件名称:testdtw(zhu)
介绍说明--下载内容均来自于网络,请自行研究使用
function dist = dtw(t,r)
n = size(t,1)
m = size(r,1)
帧匹配距离矩阵
d = zeros(n,m)
for i = 1:n
for j = 1:m
d(i,j) = sum((t(i,:)-r(j,:)).^2)
end
累积距离矩阵
D = ones(n,m) * realmax
D(1,1) = d(1,1)
动态规划
for i = 2:n
for j = 1:m
D1 = D(i-1,j)
if j>1
D2 = D(i-1,j-1)
else
D2 = realmax
end
if j>2
D3 = D(i-1,j-2)
else
D3 = realmax
end
D(i,j) = d(i,j) + min([D1,D2,D3])
end
end
dist = D(n,m) -function dist = dtw (t, r) n = size (t, 1) m = size (r, 1) fr a me matching distance matrix d = zeros (n, m) for i = 1: n for j = 1: md (i, j) = sum ((t (i,:)-r (j ,:)).^ 2) end end cumulative distance matrix D = ones (n, m)* realmax D ( 1,1) = d (1,1) dynamic programming for i = 2: n for j = 1: m D1 = D (i-1, j) if j> 1 D2 = D (i-1, j-1) else D2 = realmax end if j> 2 D3 = D (i-1, j-2) else D3 = realmax end D (i, j) = d (i, j)+ min ( [D1, D2, D3]) end end dist = D (n, m)
n = size(t,1)
m = size(r,1)
帧匹配距离矩阵
d = zeros(n,m)
for i = 1:n
for j = 1:m
d(i,j) = sum((t(i,:)-r(j,:)).^2)
end
累积距离矩阵
D = ones(n,m) * realmax
D(1,1) = d(1,1)
动态规划
for i = 2:n
for j = 1:m
D1 = D(i-1,j)
if j>1
D2 = D(i-1,j-1)
else
D2 = realmax
end
if j>2
D3 = D(i-1,j-2)
else
D3 = realmax
end
D(i,j) = d(i,j) + min([D1,D2,D3])
end
end
dist = D(n,m) -function dist = dtw (t, r) n = size (t, 1) m = size (r, 1) fr a me matching distance matrix d = zeros (n, m) for i = 1: n for j = 1: md (i, j) = sum ((t (i,:)-r (j ,:)).^ 2) end end cumulative distance matrix D = ones (n, m)* realmax D ( 1,1) = d (1,1) dynamic programming for i = 2: n for j = 1: m D1 = D (i-1, j) if j> 1 D2 = D (i-1, j-1) else D2 = realmax end if j> 2 D3 = D (i-1, j-2) else D3 = realmax end D (i, j) = d (i, j)+ min ( [D1, D2, D3]) end end dist = D (n, m)
(系统自动生成,下载前可以参看下载内容)
下载文件列表
testdtw(zhu).m