Importing data with date and time columns
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
David du Preez
el 29 de Jun. de 2016
Comentada: Star Strider
el 29 de Jun. de 2016
I have a large data set in excel. In column A are dates(2015-01-01) and in column B are times(0:00).How do I import this into Matlab?
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Jun. de 2016
Import it using the xlsread function.
I assume you already knew that, and want to know how to combine the date and time strings to create a valid date number. You can take advantage of the fact that MATLAB uses square brackets [] to concatenate strings.
Something like this will work:
dt = '2015-01-01';
tm = '12:34';
dn = datenum([dt tm], 'yyyy-mm-ddHH:MM')
ds = datestr(dn) % Check Conversion (Optional)
ds =
01-Jan-2015 12:34:00
2 comentarios
Star Strider
el 29 de Jun. de 2016
This works:
[d,s] = xlsread('David du Preez Book1.xlsx');
dn = datenum(s(2:end,1), 'mm/dd/yyyy') + d(:,1);
ds = datestr(dn) % Check Conversion (Optional)
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!