Converting serial date numbers to datetime array

42 ビュー (過去 30 日間)
Peter Marienka
Peter Marienka 2019 年 4 月 26 日
コメント済み: Peter Perkins 2019 年 5 月 3 日
Hello!
I'm sorry for bothering you all, but I'm really new to MatLab and trying to learn something new to help me with my research.
I've recently made som measurements and my outputs in txt shows time stamp in format "3718505030". I understood that this is MatLab Serial Data format, but I need to convert them into conventional data and time format. Probably the date is not included in this information. I've tried function
t = datetime(.3718505035,'ConvertFrom','datenum')
but it only converts to format HH:MM:SS, but I really need it in HH:MM:SS:SSS and also I need to apply the function on multiple rows.
Can you help me with this issue?
Thank you.

回答 (1 件)

Stephen23
Stephen23 2019 年 4 月 26 日
編集済み: Stephen23 2019 年 4 月 26 日
>> t = datetime(.3718505035,'ConvertFrom','datenum','Format','HH:mm:ss.SSS')
t =
08:55:27.883
"also I need to apply the function on multiple rows"
>> V = [0.1;0.3;0.7];
>> t = datetime(V,'ConvertFrom','datenum','Format','HH:mm:ss.SSS')
t =
02:24:00.000
07:12:00.000
16:48:00.000
  9 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 27 日
No, the user is treating the values as datenum and those are days since 1 jan 0 CE so using days() is appropriate
Peter Perkins
Peter Perkins 2019 年 5 月 3 日
Walter's right: if .3718505030 is supposed to be interpreted as "a little less than 9 hours," then using days to create a duration is the correct thing. That was one of the flaws of datenums: is it a long elapsed time, or an absolute date during the dark ages? The datetime/duration pair solves that problem.
I can't tell if it's days(.3718505030) or days(3718505030/1e10), but same difference.

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

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by