Determine if timetable is regular with respect to time or calendar unit
returns tf
= isregular(TT
,timeComponent
)1
(true
) if timetable
TT
is regular with respect to the
specified time or calendar unit. Otherwise, it returns 0
(false
). A timetable is regular if its row times increase or
decrease monotonically by the same time step.
If the row times of TT
are datetime
values, then the time steps between them might be regular with respect to a
calendar unit such as months, but irregular with respect to exact elapsed
time. Specify the time or calendar unit by using the
timeComponent
input argument.
For example, if the row times are regular monthly
datetime
values, and timeComponent
is 'month'
, then isregular
returns
1
. But if timeComponent
is
'time'
, then isregular
returns
0
because different months can represent different
lengths of time.
If the row times are duration
values, then specify
timeComponent
as 'time'
or use the
next syntax. The duration
data type does not represent
times using calendar units.
In certain cases, you can create a timetable while specifying a regular time step between row times, and yet the resulting timetable is irregular. This result occurs when you specify the time step by using a calendar unit of time and there is a row time that introduces an irregular step. For example, if you create a timetable with a time step of one calendar month, starting on January 31, 2019, then it is irregular with respect to months.
stime = datetime(2019,1,31); tstep = calmonths(1); TT = timetable('Size',[3 1],'VariableTypes',{'double'},... 'TimeStep',tstep,'StartTime',stime); tf = isregular(TT,'month')
tf = logical 0
There are other cases where irregularities are due to shifts from Daylight Saving Time (DST) or to row times that are leap seconds. This table specifies the row time values and time steps that can produce irregular timetables unexpectedly.
Row Time Value | Time Step |
---|---|
Start time specified as the 29th, 30th, or 31st day of the month. | Number of calendar months or quarters. |
Start time specified as February 29. | Number of calendar years. |
Any row time occurring between 1:00 a.m. and 2:00 a.m. on a day shifting from DST to standard time (when row times are specified as datetime values whose time zone observes DST). | Number of calendar days or months. |
Any row time that is a leap second (when row times are specified as
datetime values whose time zone is the | Time step specified in any calendar unit (days, weeks, months, quarters, or years). |
caldiff
| calendarDuration
| datetime
| diff
| duration
| issorted
| retime
| sortrows
| split
| synchronize