Thread Subject: Date and time handling question...

Subject: Date and time handling question...

From: Andrey Kazak

Date: 12 Jun, 2009 09:38:02

Message: 1 of 4

Greetings!

I have a csv file as follows:
===
Date and Time, Value,
08.06.2009 16:16:26, 3
...
===
Could you advice me please on how to import such time series in matlab for further processing, such as time interpolation please?

Prompt and clear reply would be very much appreciated...

Subject: Date and time handling question...

From: Pekka Kumpulainen

Date: 12 Jun, 2009 09:55:02

Message: 2 of 4

"Andrey Kazak" <AK@nospam.ru> wrote in message <h0t7lq$t1i$1@fred.mathworks.com>...
> Greetings!
>
> I have a csv file as follows:
> ===
> Date and Time, Value,
> 08.06.2009 16:16:26, 3
> ...
> ===
> Could you advice me please on how to import such time series in matlab for further processing, such as time interpolation please?
>
> Prompt and clear reply would be very much appreciated...

doc textscan
doc datenum

This for example seems to work:
fid = fopen('myfile.csv');
g = textscan(fid,'%s%f','headerlines',1,'delimiter',',');
fclose(fid);
time = datenum(g{1});

Subject: Date and time handling question...

From: Pekka Kumpulainen

Date: 12 Jun, 2009 10:23:01

Message: 3 of 4

"Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in message <h0t8lm$2dg$1@fred.mathworks.com>...
> "Andrey Kazak" <AK@nospam.ru> wrote in message <h0t7lq$t1i$1@fred.mathworks.com>...
> > Greetings!
> >
> > I have a csv file as follows:
> > ===
> > Date and Time, Value,
> > 08.06.2009 16:16:26, 3
> > ...
> > ===
> > Could you advice me please on how to import such time series in matlab for further processing, such as time interpolation please?
> >
> > Prompt and clear reply would be very much appreciated...
>
> doc textscan
> doc datenum
>
> This for example seems to work:
> fid = fopen('myfile.csv');
> g = textscan(fid,'%s%f','headerlines',1,'delimiter',',');
> fclose(fid);
> time = datenum(g{1});

Oops, wasn't carefun enough with the date format, this should do it
time = datenum(g{1},'dd.mm.yyyy HH:MM:SS');
or if you use month.day.year, swap the dd and mm in the format string
hth

Subject: Date and time handling question...

From: Andrey Kazak

Date: 13 Jun, 2009 04:40:17

Message: 4 of 4

Thank you, Pekka!

This works very nice...

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
date time handl... Andrey Kazak 12 Jun, 2009 05:39:08
rssFeed for this Thread

Contact us at files@mathworks.com