Access data within timerange

9 ビュー (過去 30 日間)
Thomas Horst
Thomas Horst 2020 年 7 月 11 日
コメント済み: Thomas Horst 2020 年 7 月 12 日
Hey guys,
I use timerange for accessing data in huge timetables (measurements) which works perfectly. I store these timeranges in cells.
However, in some cases it would be useful to get the starttime or endtime of a certain timerange, so another function can handle it (e. g. as a datetime). Or just to calculate the duration of the timerange.
I did not find anything like this, so I hope someone can help me! Thanks!

採用された回答

dpb
dpb 2020 年 7 月 11 日
The timerange object is another of those opaque thingies TMW has fallen in love with that has useful stuff inside it that is hidden and not documented. :(
You can get the two interval values and the type of interval as two-step process--
s=timerange(t1,t2);
ss=struct(s); % convert the timerange object to a struct that reveals internals
t1=ss.first; % retrieve the start
t2=ss.last; % end times in timerange s
However, since you have to have set t1,t2 for the timeranage object when you created it; it would be more straightforward to create your own "object" or array of objects that contains the information for the specific tmerange then. At the convenience of not having to carry those around but being able to reconstruct on demand for any specific timerange at hand.
  1 件のコメント
Thomas Horst
Thomas Horst 2020 年 7 月 12 日
Thank you so much, this is exactly what I needed!
You were right, of course, in your closing remarks. Next time I'll do it like that. Unfortunately, I already have hundreds of timeranges in my project and no more sources.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by