Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: Comparison of time entries
Replies: 11   Last Post: Apr 25, 2012 1:33 PM

 Messages: [ Previous | Next ]
 Barry Williams Posts: 251 Registered: 6/14/06
Re: Comparison of time entries
Posted: Apr 25, 2012 11:21 AM

"Johannes " <j.luthe@gmx.de> wrote in message <jn9132\$eg6\$1@newscl01ah.mathworks.com>...
> "Barry Williams" <barry.r.williamsnospam@saic.com> wrote in message <jn8vnt\$861\$1@newscl01ah.mathworks.com>...
> > "Johannes " <j.luthe@gmx.de> wrote in message <jn8tto\$t29\$1@newscl01ah.mathworks.com>...
> > > First of all thanks for your really quick answers!
> > > But I saw, that I haven't made myself clear enough and I even discovered a bad mistake in my problem described above.
> > >
> > > My original problem is what follows:
> > >
> > > start = datenum('14:32:41','hh:mm:ss') = 7.358125838078704e+005
> > > end = datenum('15:00:49','hh:mm:ss') = 7.348386255671296e+005
> > >
> > > end - start = -9.739582407408161e+002
> > >
> > > So I get for the later time a value that's smaller than that for the earlier time. How is that possible?

> >
> > Read doc datestr for permitted formats, then compare the results of using:
> > datenum('14:32:41','hh:mm:ss') and datenum('14:32:41','HH:MM:SS')
> >
> > Your problem will also be apparent if you use datestr to reverse your original entries, e.g., datestr(7.358125838078704e+005) and datestr(7.348386255671296e+005).
> > You will notice that they fall in different years because of the difficulty that Matlab has interpreting your format.
> >
> > As another matter, avoid using a keyword, like end, as a variable.
> >
> > Barry

>
> Thanks so much for your hints!
> I tried using HH:MM:SS instead of hh:mm:ss and that works really fine.
>
> To your concerns about the variable "end": In my m-file I used the German word "Ende" for this.
> I thought by translating this word into English you could possibly get the meaning of this variable better. Actually I didn't consider that "end" is a Matlab keyword.

No problem Johannes. Bitte schön. Your English is so good that I hadn't noticed it is not your native tongue.
Come to think of it, because variable (and keyword) names are case sensitive, I guess End would work as a variable as well unless there is another reason to avoid it.
Barry

Date Subject Author
4/24/12 Johannes
4/24/12 dpb
4/24/12 Steven Lord
4/25/12 Johannes
4/25/12 dpb
4/25/12 dpb
4/25/12 dpb
4/25/12 Barry Williams
4/25/12 Johannes
4/25/12 dpb
4/25/12 Barry Williams
4/25/12 Steven Lord