getsampleusingtime

Subset of a timeseries between two time values.

Category: Language Fundamentals > Data Types

Syntax

tsout = getsampleusingtime(ts, t)

Returns the sample at time t.

tsout = getsampleusingtime(ts, t1, t2)

Returns the samples with time from t1 to t2.

Description

The limits are compared with the time vector of the series, and the samples that fall inside the interval are returned, including those on the limits. Use getsamples to select by position instead.

Input arguments

ts
timeseries object.
t, t1, t2
Time values, in the units of the series.

Output arguments

tsout
timeseries with the samples in the interval.

Example

Interval in time

ts = timeseries((10:10:50)', (0:4)');
x = getsampleusingtime(ts, 1, 3);
disp(x.Time')
disp(x.Data')
Output
     1     2     3
    20    30    40

See also

getsamples getdatasamples resample timeseries gettsbetweenevents