How do I get the value of seconds in a datetime table?
16 views (last 30 days)
Show older comments
I collected some acceleration values using the matlab application, however i don't know how to convert the timestamps to seconds elapased.
2 Comments
dpb
on 3 Dec 2020
'Pends. Are the timestamps real time or some other measure?
If real time, then just subtract the first value from the data.
Answers (1)
Cris LaPierre
on 3 Dec 2020
Edited: Cris LaPierre
on 3 Dec 2020
+1 to dpb's comment. Subtracting datetimes gives you a duration. You can convert your duration to your desired units - days, hours, minutes, seconds, etc by setting the duration format. See more here.
% Create a vetor of times
t = datetime('now') + minutes(1:0.25:3)
% compute elapsed time
dt = t - t(1)
% convert elapsed time to seconds
dt.Format = 's'
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!