Read excel file with Matlab
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sanley Guerrier
le 18 Août 2023
Commenté : Star Strider
le 18 Août 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 commentaires
Réponse acceptée
Star Strider
le 18 Août 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!