Time difference in 'HH:mm:ss,SSSSSS' format
Afficher commentaires plus anciens
Hi
I have several absolute times in form of 'HH:mm:ss,SSSSSS' in a CSV (seperator is ; ).
What I need is the expired time in seconds, relative to the start time t0.
So I tried several ways:
1) Using datevec and etime
t0 = '15:30:25,123456'
t1 = '16:45:30,123457'
t0_vec = datevec(t0,'HH:mm:ss,SSSSSS') % Works only in 'HH:mm:ss'
t1_vec = datevec(t1,'HH:mm:ss,SSSSSS') % Works only in 'HH:mm:ss'
dt = etime(t1,t0);
This got me:
Error using matlab.internal.datetime.cnv2icudf (line 162)
Unrecognized second format. Format: HH:mm:ss,SSSSSS.
2) Using datetime and "-" operator
t0 = '15:30:25,123456'
t1 = '16:45:30,123457'
t0_datetime = datetime(t1,'InputFormat','HH:mm:ss,SSSSSS','Format','HH:mm:ss,SSSSSS')
t1_datetime = datetime(t1,'InputFormat','HH:mm:ss,SSSSSS','Format','HH:mm:ss,SSSSSS')
dt = t1-t0
This got me:
ans =
duration
05:32:08
(no fractional seconds.. also not when i exportet it )
Thanks for your help!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!