Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Matlab code error

13 views
Skip to first unread message

Almas

unread,
Jun 24, 2011, 11:10:21 AM6/24/11
to
Can any one help me out.... there are errors in this code
function distance = dtw(r,t)

[height width]=size(r);
[height2 width2] = size(t);

sum = 0;
sum2 = 0;

for i=1:height2
for j=1:height

for k=1:width2
sum = sum + (abs(t(i,k)-r(j,k)));
end

local_dist(i,j) = sum;
sum = 0;

end
end

[height3 width3] = size(local_dist);

accum_dist(1,1) = local_dist(1,1);

for x = 2:width3

accum_dist(1,x) = accum_dist(1,x-1)+local_dist(1,x);

end

for y = 2:height3

accum_dist(y,1) = accum_dist(y-1,1)+local_dist(y,1);

end

for a = 2:height3
for b = 2:width3

accum_dist(a,b) = local_dist(a,b) + min([accum_dist(a-1,b) accum_dist(a,b-1) accum_dist(a-1,b-1)]);

end
end

distance = accum_dist(height3, width3);

Nathan

unread,
Jun 24, 2011, 1:56:41 PM6/24/11
to Almas
Rather than just stating there are "errors in this code", please provide us those errors. (What does the error say? On which line does the error occur? etc.)

I'm a little lazy and don't want to run your code, but with an error message I am more inclined to at least try to help.

-Nathan

Roger Stafford

unread,
Jun 24, 2011, 2:01:05 PM6/24/11
to
"Almas" wrote in message <iu29ct$e9p$1...@newscl01ah.mathworks.com>...

> Can any one help me out.... there are errors in this code
> function distance = dtw(r,t)
> ...........
- - - - - - - -
This is very awkward coding. In what respect are there errors in it? Does the system give an error message, are the results not what you expect, or does it run too slowly? In any case please give full details of what you find unsatisfactory about your function.

Roger Stafford

Roger Stafford

unread,
Jun 24, 2011, 2:07:04 PM6/24/11
to
Nathan <ngre...@gmail.com> wrote in message <2ca207ff-ba15-4e52...@glegroupsg2000goo.googlegroups.com>...

> Rather than just stating there are "errors in this code", please provide us those errors. (What does the error say? On which line does the error occur? etc.)
>
> I'm a little lazy and don't want to run your code, but with an error message I am more inclined to at least try to help.
>
> -Nathan
- - - - - - - -
Nathan, when you respond to a thread you should include your response in the thread itself rather than starting a brand new thread, as you have done here. Otherwise people will not be able to understand what you are talking about.

Roger Stafford

Nathan

unread,
Jun 27, 2011, 12:39:31 PM6/27/11
to Roger Stafford

Hm. I guess google group's "new" view doesn't work correctly with TMW newsgroup?

The post that I was responding to, which you also happened to respond to, resides here: https://groups.google.com/d/topic/comp.soft-sys.matlab/svRCviX2nX0/discussion

I KNOW not to start new threads when responding to a prior thread. I've been posting here for two years (not entirely consistently, however). (I hope this response doesn't post a new thread, but if it does, I am sorry. I am using google groups and something must have changed.)

-Nathan

Roger Stafford

unread,
Jun 27, 2011, 6:28:02 PM6/27/11
to
Nathan <ngre...@gmail.com> wrote in message <bb74889f-42ba-4fe8...@glegroupsg2000goo.googlegroups.com>...
I'm sorry about that, Nathan. After posting that admonition Friday, I got to wondering if something like that might be true.

Yes, on the Matlab Newsreader, the two threads appeared separately at numbers 309700 and 309706. This thread I am replying to now is also separate at number 309795. Yet the Google thread at:

http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/b2f442be25f69d7d/c997cc5fab04c564?q=group:comp.soft-sys.matlab+insubject:Matlab+insubject:code+insubject:error

contains the contents of both 309700 and 309706, so something is haywire somewhere between Google Groups and Matlab Newsreader.

Roger Stafford

0 new messages