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!