Main Content

tscollection

Create tscollection object

Description

A tscollection object is a collection of one or more timeseries objects with the same time vector. Collections of timeseries are useful for analyzing multiple data trends that occur simultaneously.

Creation

To create a tscollection object, use the tscollection function.

Description

tsc = tscollection(ts) creates a tscollection object containing the timeseries objects in ts. The input ts can be a single timeseries object or a cell array of timeseries objects. Each timeseries must have the same time vector.

example

tsc = tscollection(timevals) defines the time vector of a tscollection.

tsc = tscollection(___,Name,Value) specifies additional options using one or more name-value arguments.

Input Arguments

expand all

Input timeseries, specified as a scalar or a cell array.

Sample times, specified as a numeric scalar or vector, or a cell array of date character vectors. 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

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: tsc = tscollection(ts,'Name','MyTSC')

tscollection name, specified as a character vector.

datenum indicator, specified as true or false. A value of true indicates that the time vector of the tscollection object consists of datenum values. For more information, see datenum.

Data Types: logical

Properties

expand all

tscollection name, represented as a character vector.

Time values, represented as a vector.

When TimeInfo.StartDate is empty, values are measured relative to 0. When TimeInfo.StartDate is defined, values represent date character vectors measured relative to the StartDate.

The length of Time must be the same as the first or the last dimension of Data for each collection.

Time information, represented as a collection of the following fields describing the time vector:

  • Units — Time units with the value 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', or 'nanoseconds'.

  • Start — Start time.

  • End — End time (read only).

  • Increment — Interval between subsequent time values (NaN when times are not uniformly sampled).

  • Length — Length of time vector (read only).

  • Format — Character vector defining the date display (see datestr).

  • StartDate — Date character vector defining the reference date (see setabstime).

  • UserData — Additional user-defined information.

To access the value of a field, use the form tsc.TimeInfo.field for a tscollection object tsc.

Object Functions

addsampletocollectionAdd sample to tscollection
addtsAdd timeseries to tscollection
delsamplefromcollectionDelete sample from tscollection
getabstimeConvert timeseries or tscollection time vector to cell array
getsampleusingtimeSubset of timeseries or tscollection data
gettimeseriesnamesNames of timeseries in tscollection
removetsRemove timeseries from tscollection
resampleResample time vector in timeseries or tscollection
setabstimeSet timeseries or tscollection times as date character vectors
settimeseriesnamesRename timeseries in tscollection

Examples

collapse all

Create a tscollection object from two timeseries objects.

ts1 = timeseries([1.1 2.9 3.7 4.0 3.0]',1:5,...
'Name','Acceleration');
ts2 = timeseries([3.2 4.2 6.2 8.5 1.1]',1:5,...
'Name','Speed');
ts = tscollection({ts1;ts2})
Time Series Collection Object: unnamed

Time vector characteristics

      Start time            1 seconds
      End time              5 seconds

Member Time Series Objects:

      Acceleration
      Speed

Version History

Introduced before R2006a