isregular
Determine if timetable is regular with respect to time or calendar unit
Description
returnstf
= isregular(TT
,timeComponent
)1
(true
) if timetableTT
isregularwith respect to the specified time or calendar unit. Otherwise, it returns0
(false
). A timetable is regular if its row times increase or decrease monotonically by the same time step.
If the row times of
TT
aredatetime
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 thetimeComponent
input argument.For example, if the row times are regular monthly
datetime
values, andtimeComponent
is'month'
, thenisregular
returns1
. But iftimeComponent
is'time'
, thenisregular
returns0
because different months can represent different lengths of time.If the row times are
duration
values, then specifytimeComponent
as'time'
or use the next syntax. Theduration
data type does not represent times using calendar units.
Examples
Input Arguments
Output Arguments
Tips
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.
开始时间指定为2月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
UTCLeapSeconds
time zone). For the list of leap seconds, seeleapseconds
.Time step specified in any calendar unit (days, weeks, months, quarters, or years).