フィルターのクリア

problem with datenum

1 回表示 (過去 30 日間)
Lu
Lu 2011 年 4 月 20 日
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 件のコメント
Walter Roberson
Walter Roberson 2011 年 4 月 20 日
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 2011 年 4 月 20 日
Thank you for pointing this out! I didnt know that but I sure wrote stuff starting with apostrophe! :)

サインインしてコメントする。

採用された回答

Laura Proctor
Laura Proctor 2011 年 4 月 20 日
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 件のコメント
Lu
Lu 2011 年 4 月 20 日
Dear Laura,
Thank you so much for your help! It worked out!!
Have a nice day :)
Laura Proctor
Laura Proctor 2011 年 4 月 20 日
I'm so glad we were able to finally get to a resolution! Good luck with your work. :o)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by