Read excel file with Matlab
6 次查看(过去 30 天)
显示 更早的评论
Hello,
I have excel file with three columns "Time", "Altitude, And "Shadow length" that I want to read in Matlab. I tried this commands below, however, the column "Time" format change to decimal number. What can I do to keep the time format the same?
Thank you!
T = readtable('Shadedata.xlsx');
opts = detectImportOptions('Shadedata.xlsx');
preview('Shadedata.xlsx',opts)
0 个评论
采纳的回答
Star Strider
2023-8-18
One option is to use the datetime 'ConvertFrom' name-value pair. For the ‘value’ argument, both 'excel' and 'posixtime' work, with 'excel' appearing to be correct (in that it gives 15-minute intervals) —
% F = fileread('Shadedata.xlsx')
% C = readcell('Shadedata.xlsx')
T = readtable('Shadedata.xlsx', 'VAriableNamingRule','preserve')
T1 = T;
T1.Time = datetime(T1.Time, 'ConvertFrom','excel')
T2 = T;
T2.Time = datetime(T2.Time, 'ConvertFrom','posixtime')
Choose the result that makes the best sense.
.
6 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!