gettsbetweenevents

Part of a timeseries lying between two events.

Category: Language Fundamentals > Data Types

Syntax

tsout = gettsbetweenevents(ts, event1, event2)

Returns the samples between the times of the two events.

tsout = gettsbetweenevents(ts, n1, n2)

Selects the events by index.

Description

Events are added with addevent. The result is a new timeseries; its Time and Data hold the selected samples. The interval runs from the time of the first event to the time of the second.

Input arguments

ts
timeseries with at least two events.
event1, event2
Event names as text, or event indices.

Output arguments

tsout
timeseries with the samples in the interval.

Example

Between two events

ts = timeseries((10:10:50)', (0:4)');
ts = addevent(ts, 'start', 1.5);
ts = addevent(ts, 'stop', 3.5);
r = gettsbetweenevents(ts, 'start', 'stop');
disp(r.Time')
disp(r.Data')
Output
     2     3
    30    40

See also

gettsafterevent gettsbeforeevent getsampleusingtime addevent timeseries