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

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??

 採用された回答

Stephan
Stephan 2019 年 2 月 26 日
編集済み: Stephan 2019 年 2 月 26 日

2 投票

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 件のコメント

Steven Lord
Steven Lord 2019 年 2 月 26 日
There's no need to take a detour through datestr to get these as a datetime array.
A = [737426.687937060 737426.687937141 737426.687937176 ]
D = datetime(A, 'ConvertFrom', 'datenum', 'Format', 'HH:mm:ss.SSS')
Alternately if you want them as a duration (time after midnight) you can do this using dateshift.
D2 = D - dateshift(D, 'start', 'day');
D2.Format = 'hh:mm:ss.SSS'
Stephan
Stephan 2019 年 2 月 26 日
Nice!
Guido Pastore
Guido Pastore 2019 年 2 月 26 日
thank you so much!
Peter Perkins
Peter Perkins 2019 年 3 月 11 日
Alternatively, timeofday(D) would also convert to a duration.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by