This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

getsampleusingtime

Subset of timeseries data

Syntax

tsout = getsampleusingtime(tsin,timeval)
tsout = getsampleusingtime(tsin,timeval,'AllowDuplicateTimes',true)
tsout = getsampleusingtime(tsin,starttime,endtime)

Description

tsout = getsampleusingtime(tsin,timeval) returns a timeseries object that contains the single data sample of an input timeseries corresponding to the time timeval.

tsout = getsampleusingtime(tsin,timeval,'AllowDuplicateTimes',true) includes multiple data samples with the same time value specified in timeval.

example

tsout = getsampleusingtime(tsin,starttime,endtime) includes samples of tsin between the times starttime and endtime.

Examples

collapse all

Create a timeseries object and extract the data samples corresponding to the 2nd through 4th time values.

tsin = timeseries((1:5)',1:5);
tsout = getsampleusingtime(tsin,2,4);
tsout.Data
ans = 3×1

     2
     3
     4

Input Arguments

collapse all

Input timeseries, specified as a scalar.

Sample time, specified as a numeric scalar, date character vector, or datenum scalar. Valid date character vectors can have the following forms:

FormatExample
dd-mmm-yyyy HH:MM:SS01-Mar-2000 15:45:17
dd-mmm-yyyy01-Mar-2000
mm/dd/yy03/01/00
mm/dd03/01
HH:MM:SS15:45:17
HH:MM:SS PM3:45:17 PM
HH:MM15:45
HH:MM PM3:45 PM
mmm.dd,yyyy HH:MM:SSMar.01,2000 15:45:17
mmm.dd,yyyyMar.01,2000
mm/dd/yyyy03/01/2000

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

Start time, specified as a numeric scalar, date character vector, or datenum scalar.

End time, specified as a numeric scalar, date character vector, or datenum scalar.

Tips

  • If the time vector in tsin is not relative to a calendar date, then starttime and endtime must be numeric.

  • If the time vector in tsin is relative to a calendar date, then starttime and endtime values must be date character vectors or datenum values.

See Also

Introduced before R2006a