problem with datenum

Hi everybody!!
I have one quick question. I´m trying to convert the dates and the timestamps of my .mat file into numbers using datenum. Dates and timestamps are in different columns, but the problem is that when I type
date=dataFile(:,1);
timestamp=dataFile(:,2);
datenumber=datenum(date,'dd.mm.yy');
timestampnumber=datenum(timestamp,'dd.mm.yy');
I get the message error
??? Error using ==> datenum at 182
DATENUM failed.
Caused by: Error using ==> datevec at 110 The input to DATEVEC was not an array of strings.
However, if I type
datafile=(finalData{:,2});
data2num=datenum(datafile);
it works but just for the first element of the dates, but I need all the elements not just one. Do you have any ideas how can I solve this?
Just one extra detail, when I type whos this is what i get
EDU>> whos date timestamp
Name Size Bytes Class Attributes
date 31591x1 4296376 cell
timestamp 31591x1 4296376 cell
I hope you could help me out with this problem
thank you and have a nice day :)

6 Commenti

Lu
Lu il 20 Apr 2011
Sorry , I made one tiny mistake in explaining my problem, it should be
timestampnumber=datenum(timestamp,'HH:MM:SS);
but the problem of datenum persists :(
Any help is welcomed :)
Andrei Bobrov
Andrei Bobrov il 20 Apr 2011
Give part of your variables: datafile, finalData
Lu
Lu il 20 Apr 2011
19.10.09
Lu
Lu il 20 Apr 2011
I dont know what is wrong, but this website keeps erasing my comments.
Basically, the dates look like 19.10.09 and the timestamps look like '08:55:02'. I think the colums are 31591x1 cells. Do you have any idea of how to make datenum work? or how else could I build 15-minutes intervals of my data set without using datenum?? Thank you so much for your help :)
Walter Roberson
Walter Roberson il 20 Apr 2011
Lourdes, if you happen to enter a line that begins and ends with either double-quote or apostrophe, then there is a bug in the recording that causes it to throw away everything else in the comment :(
Lu
Lu il 20 Apr 2011
Thank you for pointing this out! I didnt know that but I sure wrote stuff starting with apostrophe! :)

Accedi per commentare.

 Risposta accettata

Laura Proctor
Laura Proctor il 20 Apr 2011

3 voti

I believe that the error is being thrown when you are trying to create datenumber. This could be because date contains a cell array of cells. Try the following code to see if this works:
datenumber = datenum([date{:}],'dd.mm.yy');

2 Commenti

Lu
Lu il 20 Apr 2011
Dear Laura,
Thank you so much for your help! It worked out!!
Have a nice day :)
Laura Proctor
Laura Proctor il 20 Apr 2011
I'm so glad we were able to finally get to a resolution! Good luck with your work. :o)

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by