gettsbeforeatevent

Part of a timeseries up to an event, including the event time.

Category: Language Fundamentals > Data Types

Syntax

tsout = gettsbeforeatevent(ts, event)

Returns the samples at or before the event.

Description

Events are added with addevent. The result is a new timeseries; its Time and Data hold the selected samples. Samples with time up to and including the event time are kept. Compare gettsbeforeevent, which keeps only strictly earlier samples.

Input arguments

ts
timeseries with at least one event.
event
Event name as text, or the event index.

Output arguments

tsout
timeseries with the selected samples.

Example

Samples up to an event

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

See also

gettsbeforeevent gettsafteratevent gettsatevent gettsbetweenevents addevent