gettsatevent

Create timeseries at event

Syntax

tsout = gettsatevent(tsin,tsevent)
tsout = gettsatevent(tsin,tsevent,n)

Description

example

tsout = gettsatevent(tsin,tsevent) returns a timeseries object with samples occurring at the event tsevent in the input timeseries tsin. The argument tsevent can be either a tsdata.event object or a character vector containing the name of the event. When tsevent is a tsdata.event object, the time defined by tsevent specifies the time. When tsevent is a character vector, the first tsdata.event object in the Events property of tsin that matches the event name specifies the time.

tsout = gettsatevent(tsin,tsevent,n) returns a timeseries object with samples occurring at the event in tsin, where n is the number of the event occurrence for the event tsevent.

Examples

collapse all

Create a timeseries object with an event occurring at time sample 2.

tsin = timeseries((1:5)');
tsevent = tsdata.event('MyEvent',2);
tsin = addevent(tsin,tsevent);
tsin.Events
    EventData: []
         Name: 'MyEvent'
         Time: 2
        Units: 'seconds'
    StartDate: ''

Create a new timeseries object that contains the data at the event sample.

tsout = gettsatevent(tsin,'MyEvent');
tsout.Time
ans = 2

Input Arguments

collapse all

Input timeseries, specified as a scalar.

Data Types: timeseries

Event, specified as a scalar tsdata.event object or a character vector containing the name of an event.

Event number, specified as a scalar integer corresponding to the nth tsdata.event of a timeseries object.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Tips

  • When the input timeseries object tsin contains date character vectors and tsevent uses numeric time, the time selected by tsevent is treated as a date that is calculated relative to the StartDate property in tsin.TimeInfo.

  • When tsin uses numeric time and tsevent uses calendar dates, the time selected by tsevent is treated as a numeric value that is not associated with a calendar date.

Introduced before R2006a