フィルターのクリア

Read mm/dd/yy in Matlab

14 ビュー (過去 30 日間)
Theodore
Theodore 2013 年 7 月 2 日
コメント済み: Walter Roberson 2016 年 6 月 1 日
Hello!
I've been reading in an .xls file (although I'd like it to be .csv if that were possible for Matlab to read dates from) and am having trouble with it. They currently are set up in mm/dd/yy format and when read into matlab convert to a multiple digit code that I can't seem to translate back to original dates.
The first date listed is 6/1/90 and converts to the code 33025. Any ideas? Thanks!
  2 件のコメント
Nelson Mok
Nelson Mok 2016 年 6 月 1 日
Hope this help.
clear; t = readtable('ABC.xls'); datestr(x2mdate(t.Date),'mm/dd/yy')
Walter Roberson
Walter Roberson 2016 年 6 月 1 日
readtable() did not exist at the time the original question was posted.
These days you would use
t = readtable('ABC.xls');
t.Date = datetime(t.Date, 'ConvertFrom', 'Excel', 'Format', 'MM/dd/yy');

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

採用された回答

Evan
Evan 2013 年 7 月 2 日
編集済み: Evan 2013 年 7 月 2 日
That data you are reading is being brought in as a date number instead of a date string. The following function allows you to convert date numbers to date strings:
help datestr
You can specify the style that you want datestr to return like so:
d = 33025;
ds = datestr(d,2)
In this case, the 2 argument causes datestr to return in "mm/dd/yyy" format. The documentation for datestr tells what styles are available.
  2 件のコメント
Theodore
Theodore 2013 年 7 月 2 日
Worked PERFECTLY! Thanks so much!
Evan
Evan 2013 年 7 月 2 日
Great! You're welcome!

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

その他の回答 (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