MATLAB Answers

0

How can I convert a double array into a timestamp array?

Asked by Guido Pastore on 26 Feb 2019
Latest activity Commented on by Peter Perkins
on 11 Mar 2019
I have an array of double like:
ora: [737426.687937060 737426.687937141 737426.687937176 etc....]
I want to get an array like:
time:[16:30:37:762 16:30:37:769 16:30:37:772]
How can i do??

  0 Comments

Sign in to comment.

1 Answer

Answer by Stephan
on 26 Feb 2019
Edited by Stephan
on 26 Feb 2019
 Accepted Answer

Hi,
use:
B = datestr(A, 'HH:MM:SS.FFF')
B =
3×12 char array
'16:30:37.762'
'16:30:37.769'
'16:30:37.772'
to get it as datestring - or (better):
C = datetime(datestr(A, 'HH:MM:SS.FFF'),'InputFormat','HH:mm:ss.SSS','Format','HH:mm:ss.SSS')
C =
3×1 datetime array
16:30:37.762
16:30:37.769
16:30:37.772
to get it as datetime-type.
Best regards
Stephan

  4 Comments

Show 1 older comment
Alternatively, timeofday(D) would also convert to a duration.

Sign in to comment.