Read excel file with Matlab
3 views (last 30 days)
Show older comments
Sanley Guerrier
on 18 Aug 2023
Commented: Star Strider
on 18 Aug 2023
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 Comments
Accepted Answer
Star Strider
on 18 Aug 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!