Change Time and Time Format in Timetable
67 次查看(过去 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!