How do we calculate the dynamic time warping Matrix in Matlab ?

Dear Matlab Experts I have (A) matrix where the rows indicate instances (40 records) and the columns features , such as A=[20,0,5,8,...etc]; I would like to calculate the Distance matrix for A using dynamic time warping algorithm, when i used this function [Dist,D,k,w]=dtw(t,r) it just calculate the distance between the first two vectors? My question is How can I calculate the dynamic time warping Matrix in Matlab for all my 40 records? Many thanks for your cooperation in advance.

3 Comments

You posted your question 3 times in one minute...
I have delete the two other posts.
I do apologize that was happened by mistake Cause the network was not working very well at that time !!

Sign in to comment.

 Accepted Answer

Perhaps by using 2 loops? What is "t" and "r" in your example?
s2 = size(A, 2);
for col1 = 1:s2
for col2 = col1+1:s2
[Dist, D, k, w] = dtw(A(:, col1), A(:, col2));
% Now collect these values however you want
end
end

1 Comment

Many thanks Jan. That's really help me. I modified it to do the dtw between the records (rows) not the features and it is working for me now. But the issue is how can I know if my result is right !!
s2= 40;
for row1 = 1:s2
for row2 = row1+1:s2
d(row1,row2)=(A(row1)-A(row2))^2;
[dist,ix,iy,w] = dtw(A(row1,:), A(row2,:))
end
end

Sign in to comment.

More Answers (0)

Tags

Asked:

on 30 Nov 2017

Commented:

on 1 Dec 2017

Community Treasure Hunt

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

Start Hunting!