Converting date range from numeric to date format in mat file
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a mat file in which I store the data to use for analysis when needed, I wanted to past a data from excel to the mat file
This is the data I need to copy to the mat file from excel
date Inflows HPI
6/30/1985' -738.4928374 -1.376979203
9/30/1985' -149.8324882 -1.318316639
12/30/1985' -389.9021275 -1.404933598
3/30/1986' -1250.503701 -0.137879304
6/30/1986' -944.0048226 -3.060762411
9/30/1986' -64.68902275 0.169427825
12/30/1986' -278.1197318 0.049207493
3/30/1987' -507.793333 4.174160222
However, when I past the data, the date column is taken as numeric as seen below
'date' 'Inflows' 'HPI'
0.000151133501259446 -149.832488200000 -1.31831663900000
0.000201511335012594 -389.902127500000 -1.40493359800000
5.03524672708963e-05 -1250.50370100000 -0.137879304000000
0.000100704934541793 -944.004822600000 -3.06076241100000
0.000151057401812689 -64.6890227500000 0.169427825000000
0.000201409869083585 -278.119731800000 0.0492074930000000
5.03271263210871e-05 -507.793333000000 4.17416022200000
0.000100654252642174 -317.350932300000 3.98837463000000
0.000150981378963261 -289.777479600000 2.87872744700000
Is there any way to convert the date column from numeric to date format
12 comentarios
dpb
el 30 de Jun. de 2019
Still, if you have to read the Excel file for the data, it's already parsed as datetime ignoring the header so just convert that representation to datenum directly instead of parsing the same data over yet again...
Or, of course, fix the function itself to use the more better datetime instead... :)
Respuestas (1)
Steven Lord
el 28 de Jun. de 2019
If you want to store date and time data in MATLAB I strongly recommend storing it as a datetime array or in a timetable with a datetime array as the RowTimes property of the timetable. Once you have the data in a form that stores your data as datetime use something like writetable (introduced in release R2013a), writematrix (R2019a) or writetimetable (R2019a) or convert the datetime to an Excel serial date number with exceltime.
1 comentario
Ver también
Categorías
Más información sobre Spreadsheets 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!