gettsbeforeevent

Part of a timeseries strictly before an event.

Category: Language Fundamentals > Data Types

Syntax

tsout = gettsbeforeevent(ts, event)

Returns the samples with time earlier than the event.

Description

Events are added with addevent. The result is a new timeseries; its Time and Data hold the selected samples. A sample exactly at the event time is excluded; use gettsbeforeatevent to keep it.

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 before an event

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

See also

gettsbeforeatevent gettsafterevent gettsatevent gettsbetweenevents addevent