timerange — Create a timetable row-time range selector object.
timerange(startTime, endTime) returns a row-time selector with Start, End, and Inclusivity properties.
Syntax
S = timerange(startTime, endTime, intervalType)Inputs
startTime- Type
Any- Required
- Yes
- Description
- Beginning of the selected row-time interval.
endTime- Type
Any- Required
- Yes
- Description
- End of the selected row-time interval.
intervalType- Type
StringScalar- Required
- No
- Default
openright- Description
- One of openright, openleft, open, or closed.
Returns
S- Type
Any- Description
- Timetable row-time subscript selector.
Errors
RunMat:table:InvalidArgument- When
- Arguments or table metadata are invalid.
- Message
table: invalid argument
Behavior
The optional third argument is "openright", "openleft", "open", or "closed"; the default is "openright", which includes the start and excludes the end.
Datetime and duration bounds are the compatibility forms. Numeric bounds are available in runmat compatibility mode for timetables that use numeric row times.
Numeric integer bounds and numeric integer row times are ordered exactly without conversion to double.
Datetime-unit and event-filter overloads are not yet implemented.
The constructor stores Start and End without validating their shape, class, ordering, or row-time compatibility; those checks belong to indexing the target timetable. Inclusivity is case-insensitive and stored lower-case. Whitespace is trimmed and interval text is stored in canonical lower-case, matching the indexing consumer.
Exactly two bounds and an optional interval type are accepted. One scalar selector is returned; discarded output still performs admission and construction. Invalid arity, nontext inclusivity, and unsupported inclusivity use RunMat:table:InvalidArgument.
Explicit GPU arguments and numeric bounds have separate RunMat-only gates, checked before gathering. Automatically resident inputs follow the existing gather boundary; there is no selector device kernel.
Data handling and outputs
Selector metadata is host-only.
The result is a scalar host descriptor. Accepted resident payloads are gathered without changing their numeric class, shape, complexity, or exact integer values. Numeric controls follow the restrictions listed above.
Each call returns one descriptor. Calls with no retained output still validate their inputs; requesting more than one output is an error.
Example
Select A Half-Open Time Range
times = datetime(2026, 7, [1; 15; 31]);
TT = timetable(times, [10; 20; 30], 'VariableNames', {'Count'});
firstTime = datetime(2026, 7, 1);
lastTime = datetime(2026, 8, 1);
rows = timerange(firstTime, lastTime);
July = TT(rows, :)Using timerange with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how timerange changes the result.
Run a small timerange example, explain the result, then change one input and compare the output.
Related Table functions
Table
array2table · array2timetable · categorical · cell2table · dictionary · groupsummary · head · iscategorical · isordinal · istable · istimetable · ordinal · pivot · rowfilter · struct2table · table · table2array · table2cell · table2struct · table2timetable · timetable · timetable2table · uitable · vartype
Indexing
dictionary.subsasgn · dictionary.subsref · table.subsasgn · table.subsref
Source you can read
Every RunMat function's source is public. Read exactly how timerange is executed, line by line, in Rust.
- View the source for timerange in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.