How do I convert dates from excel into Matlab

11 vues (au cours des 30 derniers jours)
James Moore
James Moore le 1 Fév 2021
Réponse apportée : dpb le 1 Fév 2021
I am trying to make a time sereis plot and I am stuck at importing my times from Excel into MATLAB.
My excel files have 4 columns first is the date, second is the hour, thirs is direction and fourth is speed. How do I combine columns 1 and 2 into the format, 31-Dec-2008 23:00:00? The excel file format file is layed out below:
01/01/2012 0 250 17
01/01/2012 1 250 15
01/01/2012 2 240 16
01/01/2012 3 240 13
01/01/2012 4 240 14

Réponses (1)

dpb
dpb le 1 Fév 2021
tData=readtable('yourfile.xlsx','ReadVariableNames',0);
tData.Properties.Variablenames={'Day','Hour','WindDir','Speed'};
tData.Date=t.Day+hours(tData.Hour);
readtable will recognize the dates and import the date column as a datetime; add a duration of the hours column to build the date including the time.

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by