How do I import data from an excel sheet containing date and time (eg 10/22/14 22:45:10) in Matlab?
How do I import data from an excel sheet containing date and time (eg 10/22/14 22:45:10) in Matlab?
I recommend:
For the latter, I'll show you how to import an excel file containing dates into a table in Matlab. Be the hypothetical peso.xls file with the following data.
Data Peso
___________ ______
31-Oct-1996 174.8
29-Nov-1996 179.3
30-Dec-1996 190.4
31-Jan-1997 185.7
Now do the following.
T = readtable ('peso.xls')
T =
Data Peso
____________ ______
'10/31/1996' 174.8
'11/29/1996' 179.3
'12/30/1996' 190.4
'1/31/1997' 185.7
In windows, with Excel, the variable Data is a string field of the cell array. To convert it just do:
T.Data = datetime (T.Data, 'InputFormat', 'MM / dd / yyyy')
T =
Data Peso
___________ ______
31-Oct-1996 174.8
29-Nov-1996 179.3
30-Dec-1996 190.4
31-Jan-1997 185.7
This example was originally put into when-to -convert-dates-from-excel-files