Importing date and time from an excel file to matlab
1 回表示 (過去 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!