Time messed up after import from xls

1 回表示 (過去 30 日間)
Shi Shu
Shi Shu 2013 年 8 月 15 日
In an excel file, I have a column of time data as
12:00:00 AM
12:00:01 AM
12:00:02 AM
12:00:03 AM
12:00:04 AM
12:00:05 AM
when I import this column to Matlab, the data look like:
0
1.15740740740741e-05
2.31481481481481e-05
3.47222222222222e-05
4.62962962962963e-05
5.78703703703704e-05
and when i use the datastr to convert, the results look like this:
00:01:00
00:01:01
00:01:02
00:01:03
00:01:04
00:01:05
Where does the additional 1 minute come from?? I suspect it's about the accuracy of the numbers. Not sure though.
Please help. Thanks!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 15 日
d=[0
1.15740740740741e-05
2.31481481481481e-05
3.47222222222222e-05
4.62962962962963e-05
5.78703703703704e-05]
datestr(d,'HH:MM:SS')
  1 件のコメント
Shi Shu
Shi Shu 2013 年 8 月 15 日
編集済み: Azzi Abdelmalek 2013 年 8 月 15 日
Thanks, Azzi. I think this helped me out. Please try this code and you will see something interesting. I didn't expect the case of the letters can make this different.
d=[0;
1.15740740740741e-05;
2.31481481481481e-05;
3.47222222222222e-05;
4.62962962962963e-05;
5.78703703703704e-05];
datestr(d,'hh:mm:ss')

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

その他の回答 (1 件)

Jan
Jan 2013 年 8 月 15 日
Excel stores date as serial date numbers, which are not identical to Matlab's serial date format. See http://www.mathworks.com/matlabcentral/answers/64198#answer_75809 for an answer.
  1 件のコメント
Shi Shu
Shi Shu 2013 年 8 月 15 日
Thank you, Jan.

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by