This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Determine whether times in timetable are regular


TF = isregular(TT)
TF = isregular(TT,unit)
[TF,dt] = isregular(___)



TF = isregular(TT) returns 1 (true) if the row times in the timetable TT are regular. Otherwise, it returns 0 (false). 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.


TF = isregular(TT,unit) returns 1 (true) if the row times are regular with respect to the calendar duration unit specified by unit. For example, if the row times are datetime values whose year and month components are regular to the month, and unit is 'month', then isregular returns 1.


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


collapse all

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=5x1 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 array

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 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=5x1 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.

Calendar duration unit, specified as a character vector. isregular determines 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.

Time 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

Regularity of row times, 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 a calendar duration. If the timetable is not regular, then dt is a NaN value.

Introduced in R2016b

Was this topic helpful?