Main Content

getdatasamples

Access timeseries data samples

Description

Note

The getdatasamples function applies to objects created using the timeseries function. For information on getting data from a timetable, which is recommended over timeseries and tscollection, see Select Times in Timetable.

tsdata = getdatasamples(ts,ind) returns the data of a timeseries object ts corresponding to the indices in ind. The data in tsdata corresponds to the time samples in ts.time(ind).

example

Examples

collapse all

Create a timeseries object, and extract the second and third data samples.

ts = timeseries((1:5)');
tsdata = getdatasamples(ts,[2,3])
tsdata = 2×1

     2
     3

Input Arguments

collapse all

Input timeseries, specified as a scalar.

Data Types: timeseries

Row or column indices, specified as a positive integer numeric scalar or vector. ind represents column indices for column-oriented data (ts.IsTimeFirst is true) and represents row indices for row-oriented data (ts.IsTimeFirst is false).

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

Version History

Introduced before R2006a