check if the time vector is regular
t = isregular(x) t = isregular(x, timeUnit) [t, step] = isregular(x) [t, step] = isregular(x, timeUnit)
string with possible values "years", "months", "days" or "time" (default value)
boolean
time step regular (%nan if x is not regular)
The isregular function checks if the time vector contains values with fixed time step.
isregular(x) returns %t if x is a duration or datetime vector with regular time step.
isregular(x, timeUnit) returns %t if x has a regular time step according to TimeUnit. Be careful, a datetime vector whose time step is a month will not be regular because the number of days differs between the months. To check that this vector is regular in months, use "months" as timeUnit: isregular(x, "months").
The step argument contains the time step when x is regular.
With duration
d = hours(0:2:10); [a, b] = isregular(d) | ![]() | ![]() |
With datetime
dt = datetime(2000, 1, 1): calmonths(2): datetime(2001, 1, 1); [a, b] = isregular(dt) [a, b] = isregular(dt, "months") | ![]() | ![]() |
With timeseries
Time = duration(0,0:10, 0)'; Temperature = [38 37.5 37.4 37.5 37.1 37.6 37.7 38.2 37.8 37 38.3]'; ts = timeseries(Time, Temperature, "VariableNames", ["Time", "Temp"]); [a, b] = isregular(ts) | ![]() | ![]() |
Version | Description |
2024.0.0 | Introduction in Scilab. |