Create a time array
Show older comments
Hey guys, thanks in advance.
I have one matrix of data( this is a char data) that has two times : as visible in this figure
'Canal zero_timestamp.mat'

those numbers are: hour-minutes-seconds-miliseconds
I need to produce a time array with duration in seconds between first element of this matrix and the last element(17-11-09_923).
I wanted to conserve the miliseconds, is there anyway?
Accepted Answer
More Answers (2)
Fangjun Jiang
on 30 Jun 2022
Edited: Fangjun Jiang
on 30 Jun 2022
val=['17-10-58_086'
'17-11-09_923']
StartEnd=datetime(val,'InputFormat','HH-mm-ss_SSS')
TimeVector=StartEnd(1):seconds(1):StartEnd(2)
datestr(TimeVector,'HH-MM-SS_FFF')
val = [ ...
'17-10-58_086'; ...
'17-11-09_923'; ...
]
dt = datetime(val,'InputFormat','HH-mm-ss_SSS')
dt_diff = dt(end)-dt(1)
% the milliseconds are present in dt_diff:
seconds(dt_diff)
milliseconds(dt_diff)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!