I've got a .xlsx file with parts like this:
I want to import that into MATLAB like this:
[data,txt,raw]=xlsread('filename','D1:D6')
But it becomes:
{'2019/5/26 8:17:41'}
{'2019/5/26 8:17:41'}
{'2019/5/26 8:17:41'}
{'2019/5/26 8:17:41'}
{'2019/5/26 8:17:41'}
{'2019/5/26 8:17:41'}
which rounds my original data to seconds, BUT I need to keep the milliseconds.
When I open the data file in Excel, I realized where the wrong data comes from.
And now my question: Is there a way to import the original data like 2019-05-26 08:17:40.501
into MATLAB? Both datestr or datenum can be accepted, only if it contains the same thing with original data.
I can't find out any clue in doc xlsread
or doc importdata
to deal with this issue. Also I've seen this question on StackOverflow , which has similar data with mine but with totally different result, and I'd assume to be a different issue.
Thanks to @Phil Goddard, this issue is fixed with readtable
, namely:
raw=readtable('filename');
the result is a table
As you see, everything goes well. The time data is actually a datetime
vector, which can be checked by raw{:,4}
, and can be converted to datenum or datestr or anything you like.
Generally, use readtable
instead of xlsread
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.