From: Dustin on
I am importing data that is a cell array of dates. I would like to be able to convert this to an array of serial dates so I can do some basic manipulation (like how many minutes between the first and last time stamp).

Whos output bellow as well as the first couple in the series. Thanks!

Name Size Bytes Class Attributes
dateAR 25x1 2416 cell


'8/4/2010'
'8/4/2010 1:00:00 AM'
'8/4/2010 2:00:00 AM'
'8/4/2010 3:00:00 AM'
etc...
From: Joseph on
Check out: datenum()


"Dustin " <dbrisset(a)gmail.com> wrote in message <i3enl4$me7$1(a)fred.mathworks.com>...
> I am importing data that is a cell array of dates. I would like to be able to convert this to an array of serial dates so I can do some basic manipulation (like how many minutes between the first and last time stamp).
>
> Whos output bellow as well as the first couple in the series. Thanks!
>
> Name Size Bytes Class Attributes
> dateAR 25x1 2416 cell
>
>
> '8/4/2010'
> '8/4/2010 1:00:00 AM'
> '8/4/2010 2:00:00 AM'
> '8/4/2010 3:00:00 AM'
> etc...
From: Dustin on
Thanks,

it works. I was trying to use that trying to anticipate the format early and must of been making a mistake with that. Thanks for the easy fix.

"Joseph " <don'twannapostit(a)nopers.com> wrote in message <i3eoms$1ds$1(a)fred.mathworks.com>...
> Check out: datenum()
>
>
> "Dustin " <dbrisset(a)gmail.com> wrote in message <i3enl4$me7$1(a)fred.mathworks.com>...
> > I am importing data that is a cell array of dates. I would like to be able to convert this to an array of serial dates so I can do some basic manipulation (like how many minutes between the first and last time stamp).
> >
> > Whos output bellow as well as the first couple in the series. Thanks!
> >
> > Name Size Bytes Class Attributes
> > dateAR 25x1 2416 cell
> >
> >
> > '8/4/2010'
> > '8/4/2010 1:00:00 AM'
> > '8/4/2010 2:00:00 AM'
> > '8/4/2010 3:00:00 AM'
> > etc...
From: Joseph on
No problemo.

A couple words of warning:
a. using 10 and 2010 for dates will yield different results (not surprising but still)
b. Leaving the input in a string format (i.e. Jan-21-2001) results in a long runtime (probably not important for 25 dates)


"Dustin " <dbrisset(a)gmail.com> wrote in message <i3eqqe$h4q$1(a)fred.mathworks.com>...
> Thanks,
>
> it works. I was trying to use that trying to anticipate the format early and must of been making a mistake with that. Thanks for the easy fix.
>
> "Joseph " <don'twannapostit(a)nopers.com> wrote in message <i3eoms$1ds$1(a)fred.mathworks.com>...
> > Check out: datenum()
> >
> >
> > "Dustin " <dbrisset(a)gmail.com> wrote in message <i3enl4$me7$1(a)fred.mathworks.com>...
> > > I am importing data that is a cell array of dates. I would like to be able to convert this to an array of serial dates so I can do some basic manipulation (like how many minutes between the first and last time stamp).
> > >
> > > Whos output bellow as well as the first couple in the series. Thanks!
> > >
> > > Name Size Bytes Class Attributes
> > > dateAR 25x1 2416 cell
> > >
> > >
> > > '8/4/2010'
> > > '8/4/2010 1:00:00 AM'
> > > '8/4/2010 2:00:00 AM'
> > > '8/4/2010 3:00:00 AM'
> > > etc...
From: Dustin on
As for b. I am actually running a few thousand points which was part of the desire for serial dates. But now I have a new problem that you might be able to help me with.

For some reason datenum is rounding to the day precision, where i need precision at the second level.

As before

dateAR(1:4,1)

ans =

'8/4/2010'
'8/4/2010 1:00:00 AM'
'8/4/2010 2:00:00 AM'
'8/4/2010 3:00:00 AM'

format long; datenum(dateAR(1:4,1))

ans =

734354
734354
734354
734354

datestr(datenum(dateAR(1:4,:)), 'HH:MM:SS')

ans =

00:00:00
00:00:00
00:00:00
00:00:00

The only work around i have found is including datenum on every element of the original vector. This is far from desirable for several reasons.

datenum(dateAR(2))-datenum(dateAR(1))
ans =

0.041666666627862

Thanks again!


"Joseph " <don'twannapostit(a)nopers.com> wrote in message <i3es99$l95$1(a)fred.mathworks.com>...
> No problemo.
>
> A couple words of warning:
> a. using 10 and 2010 for dates will yield different results (not surprising but still)
> b. Leaving the input in a string format (i.e. Jan-21-2001) results in a long runtime (probably not important for 25 dates)
>
>
> "Dustin " <dbrisset(a)gmail.com> wrote in message <i3eqqe$h4q$1(a)fred.mathworks.com>...
> > Thanks,
> >
> > it works. I was trying to use that trying to anticipate the format early and must of been making a mistake with that. Thanks for the easy fix.
> >
> > "Joseph " <don'twannapostit(a)nopers.com> wrote in message <i3eoms$1ds$1(a)fred.mathworks.com>...
> > > Check out: datenum()
> > >
> > >
> > > "Dustin " <dbrisset(a)gmail.com> wrote in message <i3enl4$me7$1(a)fred.mathworks.com>...
> > > > I am importing data that is a cell array of dates. I would like to be able to convert this to an array of serial dates so I can do some basic manipulation (like how many minutes between the first and last time stamp).
> > > >
> > > > Whos output bellow as well as the first couple in the series. Thanks!
> > > >
> > > > Name Size Bytes Class Attributes
> > > > dateAR 25x1 2416 cell
> > > >
> > > >
> > > > '8/4/2010'
> > > > '8/4/2010 1:00:00 AM'
> > > > '8/4/2010 2:00:00 AM'
> > > > '8/4/2010 3:00:00 AM'
> > > > etc...
 |  Next  |  Last
Pages: 1 2
Prev: Read data from txt
Next: Writting overloaded function