Change Time and Time Format in Timetable
72 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Cris LaPierre
on 15 May 2023
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
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!