From: LEI CAO on
Hi-

I'm a new user of MatLab, facing a problem of date/time data transform.

the data obtained from excel are:

'2010-4-25 8:38:00'
'2010-4-25 8:41:00'
....

And it seems not to be a string type...

How do I extract the date and time info., count the number of data in each hour, and calculate the time interval?

Thanks

CAO, LEI
From: LEI CAO on
This may give a better description of the data.

[numeric, txt, raw]=xlsread(FILE);
raw=
'2010-1-25 0:01:00' [0.1780] [1.2527] [178.8000] [0.9010]
'2010-1-25 0:05:00' [0.1890] [1.2527] [178.8000] [0.9010]
'2010-1-25 0:13:00' [0.1870] [1.2528] [178.6000] [0.9010]
.......

The date and time info are needed from them.

I'd appreciate any help. Thanks
From: TideMan on
On Apr 25, 4:23 pm, "LEI CAO" <chris_...(a)hotmail.com> wrote:
> This may give a better description of the data.
>
> [numeric, txt, raw]=xlsread(FILE);
> raw=
> '2010-1-25 0:01:00'    [0.1780]    [1.2527]    [178.8000]    [0.9010]
> '2010-1-25 0:05:00'    [0.1890]    [1.2527]    [178.8000]    [0.9010]
> '2010-1-25 0:13:00'    [0.1870]    [1.2528]    [178.6000]    [0.9010]
> ......
>
> The date and time info are needed from them.
>
> I'd appreciate any help. Thanks

t=datenum(txt(:,1),'yyyy-mm-dd HH:MM:SS');
should do it.
Now t is a vector Matlab days that you can manipulate numerically.


From: LEI CAO on
It does. And 'datestr' does also.

Thank you

> t=datenum(txt(:,1),'yyyy-mm-dd HH:MM:SS');
> should do it.
> Now t is a vector Matlab days that you can manipulate numerically.
>