Reading a time column
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shahar ben ezra
el 2 de Mayo de 2021
Comentada: Star Strider
el 2 de Mayo de 2021
Hello
I have a CSV file, with columns of times
When I read the file by readmatrix or readcell or readtable
I get columns of values rather than times
How can I fix the problem?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/604430/image.png)
0 comentarios
Respuesta aceptada
Star Strider
el 2 de Mayo de 2021
Here is one approach —
Excel_Val = '16:50:13' % Original
MATLAB_Val = rem(datenum(Excel_Val, 'HH:MM:SS'),1) % Fraction-Of-Day Representration
dt = datetime(MATLAB_Val, 'ConvertFrom','datenum', 'Format','HH:mm:ss') % ‘datetime’ Conversion
.
2 comentarios
Star Strider
el 2 de Mayo de 2021
As always, my pleasure!
The 1 in the rem call isolates the decimal fraction part of the floating-point argument to it.
For example —
arg = pi
decfrax_arg = rem(arg,1)
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis 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!