How to read time as string data from excel file
조회 수: 15 (최근 30일)
이전 댓글 표시
I used readtable to read time from excel spread sheets. The time was converted to double like e.x. But I want to read time as original form. How does read time as string?
e.x 10:11:09 AM => 0.42858
댓글 수: 0
채택된 답변
Yutaka Yamada
2021년 5월 24일
How about the below code if you want to use readtable?
opts = detectImportOptions('readTime.xlsx');
opts.VariableTypes = 'datetime';
T = readtable('readTime.xlsx', opts);
for i = 1:3
a = T{i, 1};
a.Format = 'HH:mm:ss a';
end
I've attached the Excel file that I've used for this test also.
댓글 수: 3
추가 답변 (1개)
Sulaymon Eshkabilov
2021년 5월 24일
Hi,
You should try using xlsread() in this case. In fact, xlsread is slower than readtable().
Then you can employ datenum() and datestr() if necessary.
Good luck.
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!