Importing date and time from an excel file to matlab
2 次查看(过去 30 天)
显示 更早的评论
I have an excel file with data that looks like this
Date Time PM10
5/29/14 6:01 0.148
5/29/14 6:03 0.148
5/29/14 6:05 0.121
5/29/14 6:07 0.123
5/29/14 6:09 0.169
5/29/14 6:11 0.129
5/29/14 6:13 0.124
I want to import it into matlab as table such that mytable.Date would be the first column, and mytable.Time would be second column in the same format as in the excel file and mytable.PM10 would be the third column. I am currently using this code.
PM10data = readtable('PM10 data June 2014 - September 2015.xlsx');
However, the output I get looks like this
'5/29/2014' 0.250775462962963 0.148000000000000
'5/29/2014' 0.252164351851852 0.148000000000000
'5/29/2014' 0.253553240740741 0.121000000000000
'5/29/2014' 0.254942129629630 0.123000000000000
'5/29/2014' 0.256331018518519 0.169000000000000
'5/29/2014' 0.257719907407407 0.129000000000000
'5/29/2014' 0.259108796296296 0.124000000000000
I realize that it converts the time into a datenum but I want it to be a string. How do I fix this? Thank you!
0 个评论
回答(2 个)
Martin Schätz
2015-10-18
Hi, you can use datestr() function
>> datestr(0.250775462962963)
ans =
6:01 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!