Change Time and Time Format in Timetable
조회 수: 23 (최근 30일)
이전 댓글 표시

So I have this timetable called 'pleth' and I want to change the Record Time column. I have a starting point of '28-Apr-2022 22:02:11' and to that I want to add the seconds from the Record Time column.
Meaning, I want something like this:
28-Apr-2022 22:05:11
28-Apr-2022 22:05:21
28-Apr-2022 22:05:31
28-Apr-2022 22:05:41
... and so on.
I have tried this, but haven't had any success:
for i=1:size(pleth,1)
date=datetime(2022, 4, 28);
sec=seconds(pleth.Properties.RowTimes(i));
pleth.Properties.RowTimes(i) = date + duration(22, 2, 11+sec, 'Format', 'hh:mm:ss');
end
When I try this:
pleth.Properties.RowTimes(4) = duration(22, 02, 11 + seconds(pleth.Properties.RowTimes(4)), 'Format', 'hh:mm:ss')
The Time in row 4 changes, but the format is still in seconds. And the date still needs to be added.

Any help would be much appreciated!!
댓글 수: 0
채택된 답변
Cris LaPierre
2023년 5월 15일
You can just create a datetime with your start time, and then add your record time to it.
Time = seconds(0:10:100)';
Data = rand(size(Time));
pleth = timetable(Time, Data)
startTime = datetime(2022,04,28,22,05,11)
pleth.Time = pleth.Time + startTime
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!