xlsread problem with datenum
1 view (last 30 days)
Show older comments
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 Comment
Jan
on 1 Nov 2015
If you post the relevant part of the code, suggesting a modification is easier and more likely to match your needs.
Answers (1)
Jan
on 1 Nov 2015
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'});
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!