MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Make Timetable Regular


Create a regular timetable using retime. Interpolate the data onto a regular hourly time
vector. To use linear interpolation, specify 'linear'. Each row time in TT begins on the
hour, and there is a one-hour interval between consecutive row times.


TT = retime(TT,'hourly','linear')


TT=6×4 timetable
Time Temp Rain WindSpeed




09-Jun-2016 05:00:00 65.826 0.0522 3.0385
09-Jun-2016 06:00:00 72.875 0.010737 2.3129
09-Jun-2016 07:00:00 66.027 0.044867 1.6027
09-Jun-2016 08:00:00 59.158 0.079133 0.9223
09-Jun-2016 09:00:00 70.287 0.013344 2.8171
09-Jun-2016 10:00:00 62.183 0.031868 3.4654


Instead of using a predefined time step such as 'hourly', you can specify a time step of
your own. To specify a time step of 30 minutes, use the 'regular' input argument and
the 'TimeStep' name-value pair argument. You can specify a time step of any size as a
duration or calendar duration value.


TT = retime(TT,'regular','linear','TimeStep',minutes(30))


TT=11×4 timetable
Time Temp Rain WindSpeed




09-Jun-2016 05:00:00 65.826 0.0522 3.0385
09-Jun-2016 05:30:00 69.35 0.031468 2.6757
09-Jun-2016 06:00:00 72.875 0.010737 2.3129
09-Jun-2016 06:30:00 69.451 0.027802 1.9578
09-Jun-2016 07:00:00 66.027 0.044867 1.6027
09-Jun-2016 07:30:00 62.592 0.062 1.2625
09-Jun-2016 08:00:00 59.158 0.079133 0.9223
09-Jun-2016 08:30:00 64.722 0.046239 1.8697
09-Jun-2016 09:00:00 70.287 0.013344 2.8171
09-Jun-2016 09:30:00 66.235 0.022606 3.1412
09-Jun-2016 10:00:00 62.183 0.031868 3.4654


Clean Timetable with Missing, Duplicate, or Nonuniform Times
Free download pdf