Main Content

gettsbetweenevents

Createtimeseriesbetween events

Description

example

tsout = gettsbetweenevents(tsin,tsevent1,tsevent2)返回一个timeseriesobject with samples occurring between the eventstsevent1andtsevent2in the inputtimeseriestsin. The argumentstsevent1andtsevent2can be eithertsdata.eventobjects or character vectors containing the names of the events. Whentsevent1andtsevent2aretsdata.eventobjects, the times defined by the events specify the time. Whentsevent1andtsevent2are character vectors, the firsttsdata.eventobject in theEventsproperty oftsinthat matches the event names specifies the time.

tsout = gettsbeforeevent(tsin,tsevent1,tsevent2,n1,n2)返回一个timeseriesobject with samples between two events intsin, wheren1is the number of the event occurrence fortsevent1andn2is the number of the event occurrence fortsevent2.

Examples

collapse all

Create atimeseriesobject with events occurring at time samples 1 and 3.

tsin = timeseries((1:5)'); tsevent1 = tsdata.event('StartEvent',1); tsevent2 = tsdata.event('EndEvent',3); tsin = addevent(tsin,[tsevent1 tsevent2]);

Create a newtimeseriesobject that contains the data between the two event samples.

tsout = gettsbetweenevents(tsin,'StartEvent','EndEvent'); tsout.Time
ans =3×11 2 3

Input Arguments

collapse all

Inputtimeseries, specified as a scalar.

Data Types:timeseries

Start event, specified as a scalartsdata.eventobject or a character vector containing the name of an event.

End event, specified as a scalartsdata.eventobject or a character vector containing the name of an event.

Start event number, specified as a scalar integer corresponding to then1tsdata.eventof atimeseriesobject.

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

End event number, specified as a scalar integer corresponding to then2tsdata.eventof atimeseriesobject.

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

Tips

  • When the inputtimeseriesobjecttsincontains date character vectors andtsevent1andtsevent2use numeric time, the time selected is treated as a date that is calculated relative to theStartDateproperty intsin.TimeInfo.

  • Whentsinuses numeric time andtsevent1andtsevent2use calendar dates, the time selected is treated as a numeric value that is not associated with a calendar date.

Version History

Introduced before R2006a