Determine whether times in timetable are regular
TF = isregular(TT)
TF = isregular(TT,unit)
[TF,dt] = isregular(___)
TF = isregular(
if the row times in the timetable
TT are regular.
Otherwise, it returns
The row times are regular if they increase or decrease monotonically
by a fixed time step. For example, if consecutive row times always
differ by one second, then the times are regular.
Create a timetable using a monthly time vector. Determine whether it is regular with respect to time, and then with respect to months.
Create a timetable whose row times are the first five months of the year
2016. Add the monthly price of a stock as a table variable.
StockPrice = [109.0;107.82;113.17;128.01;116]; M = timetable(datetime(2016,1:5,3)',StockPrice)
M=5×1 timetable Time StockPrice ___________ __________ 03-Jan-2016 109 03-Feb-2016 107.82 03-Mar-2016 113.17 03-Apr-2016 128.01 03-May-2016 116
M is a regular timetable.
TF = isregular(M)
TF = logical 0
M is not regular because the first five months have different numbers of days. You can use the
diff function to calculate the differences in the time steps between consecutive times in
M. The differences are durations, formatted to display the time steps as hours, minutes, and seconds.
D = diff(M.Time)
D = 4x1 duration array 744:00:00 696:00:00 744:00:00 720:00:00
M is regular with respect to months, by specifying
'month' as the unit of measure.
TF = isregular(M,'months')
TF = logical 1
Create a timetable. Determine if it is regular, and return the size of the time step if it is.
Time = [minutes(0):minutes(15):minutes(60)]'; Pulse = [72 75 80 73 69]'; TT = timetable(Time,Pulse)
TT=5×1 timetable Time Pulse ______ _____ 0 min 72 15 min 75 30 min 80 45 min 73 60 min 69
[TF,dt] = isregular(TT)
TF = logical 1
dt = duration 15 min
TT is a regular timetable.
TT— Input timetable
unit— Calendar duration unit
Calendar duration unit, specified as a character vector.
if the row times of
TT are regular to the calendar
unit specified by
unit. The table lists the calendar
duration units you can specify.
Regular to the year
Regular to the quarter
Regular to the month
Regular to the week
Regular to the day
Regular with respect to time
TF— Regularity of row times
Regularity of row times, returned as a logical
the row times are regular, and a logical
0 if they
dt— Time step between row times
Time step between row times, returned as a duration or a calendar
duration. If the timetable is not regular, then