How to make a table with date times and durations?

조회 수: 38 (최근 30일)
HWIK
HWIK 2021년 7월 19일
답변: dpb 2021년 7월 19일
Hi, I have a set of datetimes and durations, and I want to merge them and display them in a table. I just can't figure out how to set the timezones, keep on getting errors. Any help is appreciated, I attached the files for extra clarity.
Thanks!

채택된 답변

dpb
dpb 2021년 7월 19일
>> t=table(rampD_start,rampD_end,'VariableNames',{'Start','End'});
>> head(t)
ans =
8×2 table
Start End
____________ ____________
May-03 11:37 May-03 11:55
May-05 11:00 May-05 11:07
May-21 12:00 May-21 12:24
May-25 17:23 May-25 17:43
May-26 11:37 May-26 12:00
May-28 11:39 May-28 12:01
May-31 12:18 May-31 12:41
Jun-02 10:20 Jun-02 10:42
>> t.Span=t.End-t.Start;
Cannot combine or compare a datetime array with a time zone with one without a time zone.
>> t.Start.TimeZone
ans =
0×0 empty char array
>> t.End.TimeZone
ans =
'Europe/Amsterdam'
>> t.Start.TimeZone=t.End.TimeZone;
>> t.Span=t.End-t.Start;
>> head(t)
ans =
8×3 table
Start End Span
____________ ____________ ________
May-03 11:37 May-03 11:55 00:18:00
May-05 11:00 May-05 11:07 00:07:00
May-21 12:00 May-21 12:24 00:24:00
May-25 17:23 May-25 17:43 00:20:00
May-26 11:37 May-26 12:00 00:23:00
May-28 11:39 May-28 12:01 00:22:00
May-31 12:18 May-31 12:41 00:23:00
Jun-02 10:20 Jun-02 10:42 00:22:00
>>
Or, of course, you can remove the TimeZone from both if don't want to keep it.
Alternatively, go back to the creation of the data from which the two datetime arrays came and ensure they're imported the same way to avoid the mismatch in the beginning.

추가 답변 (1개)

Sameer Pujari
Sameer Pujari 2021년 7월 19일
Table can be found simply using this
T=table(rampD_start,rampD_end,rampD_dur)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by