xlsread problem with datenum
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
When importing an xls file made of two columns: the first of timestamp and the second of value, I have an error doing the datenum on the timestamp cell. Indeed, the problem is how xlsread import the excel dates. In the last value you can see that the excel date '11/1/2015 00:00:00' is truncated and thus datenum do not find the correct format. Do you know how I can convert in a fast and easy way this format?
'10/31/2015 11:59:29 PM' [159510]
'10/31/2015 11:59:34 PM' [159527]
'10/31/2015 11:59:42 PM' [159528]
'10/31/2015 11:59:43 PM' [159536]
'11/1/2015' [159537]
Thanks a lot
1 个评论
Jan
2015-11-1
If you post the relevant part of the code, suggesting a modification is easier and more likely to match your needs.
回答(1 个)
Jan
2015-11-1
You can append the trailing time string manually:
C = {'10/31/2015 11:59:29 PM'; ...
'10/31/2015 11:59:34 PM'; ...
'10/31/2015 11:59:42 PM'; ...
'10/31/2015 11:59:43 PM'; ...
'11/1/2015'};
Cropped = cellfun('length', C) < 10;
C(Cropped) = strcat(C(Cropped), {' 00:00:00 AM'});
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!