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 tscollection data

Syntax

tscout = getsampleusingtime(tscin,timeval)
tscout = getsampleusingtime(tscin,timeval,'AllowDuplicateTimes',true)
tscout = getsampleusingtime(tscin,starttime,endtime)

Description

tscout = getsampleusingtime(tscin,timeval) returns a tscollection object that contains the single data sample of an input tscollection corresponding to the time timeval.

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

example

tscout = getsampleusingtime(tscin,starttime,endtime) includes samples of tscin between the times starttime and endtime.

Examples

collapse all

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

ts1 = timeseries(rand(5,1),'Name','ts1');
ts2 = timeseries(rand(5,1),'Name','ts2');
tscin = tscollection({ts1,ts2});

tscout = getsampleusingtime(tscin,2,4);
tscout.Time
ans = 3×1

     2
     3
     4

Input Arguments

collapse all

Input tscollection, 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 tscin is not relative to a calendar date, then starttime and endtime must be numeric.

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

Introduced before R2006a