Converting a time field (+000:00:00) in a table to a usable format

1 view (last 30 days)
Hello, I am trying to plot signal data in a table that has seems to be in HH:MM:ss format. I am trying to convert the time column to seconds but have been having issues using datetime. I am using readtable to convert the data from excel but unsure how to proceed. Thank you!

Answers (1)

Star Strider
Star Strider on 14 Sep 2022
Use the second function with the 'secondoofday' argument (or whatever you want from it) —
format long G
dt = datetime('now','Format','yyyy-MM-dd HH:mm:ss.SSSSSS') + minutes(0:0.1:1).'
dt = 11×1 datetime array
2022-09-14 14:32:15.021989 2022-09-14 14:32:21.021989 2022-09-14 14:32:27.021989 2022-09-14 14:32:33.021989 2022-09-14 14:32:39.021989 2022-09-14 14:32:45.021989 2022-09-14 14:32:51.021989 2022-09-14 14:32:57.021989 2022-09-14 14:33:03.021989 2022-09-14 14:33:09.021989 2022-09-14 14:33:15.021989
dts = second(dt,'secondofday')
dts = 11×1
1.0e+00 * 52335.021989 52341.021989 52347.021989 52353.021989 52359.021989 52365.021989 52371.021989 52377.021989 52383.021989 52389.021989
See the documentation section on secondType for other options.
.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!