Main Content


Determine if timetable is regular with respect to time or calendar unit



tf = isregular(TT,timeComponent) returns 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.


tf = isregular(TT) is equivalent to isregular(TT,'time').


[tf,dt] = isregular(___) returns dt, the time step between row times. If TT is regular, then dt is either a duration value or a calendarDuration value. If TT is not regular, then dt is a NaN value.


collapse all

Create a timetable by 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  

Determine whether M is a regular timetable.

TF = isregular(M)
TF = logical

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

Determine whether M is regular with respect to months by specifying 'month' as the unit of measure.

TF = isregular(M,'months')
TF = logical

Create a timetable. Determine if it is regular, and then 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

dt = duration
   15 min

TT is a regular timetable.

Input Arguments

collapse all

Input timetable.

Time or calendar unit, specified as a character vector or string scalar. isregular determines if the row times of TT are regular to the time or calendar unit specified by timeComponent. The table lists the units that you can specify.

Time or Calendar Unit



Regular to the year


Regular to the quarter


Regular to the month


Regular to the week


Regular to the day

'time' (default)

Regular with respect to time

Output Arguments

collapse all

True or false, returned as a logical 1 if the row times are regular and a logical 0 if they are not.

Time step between row times, returned as a duration or calendarDuration value. If the timetable is not regular, then dt is a NaN value.


  • 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'},...
    tf = isregular(TT,'month')
    tf =

    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 UTCLeapSeconds time zone). For the list of leap seconds, see leapseconds.

    Time step specified in any calendar unit (days, weeks, months, quarters, or years).

Extended Capabilities

Introduced in R2016b