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.


Create tscollection object


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.


To create a tscollection object, use the tscollection function.


tsc = tscollection(ts)
tsc = tscollection(timevals)



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.

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

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:

dd-mmm-yyyy HH:MM:SS01-Mar-2000 15:45:17
HH:MM:SS PM3:45:17 PM
mmm.dd,yyyy HH:MM:SSMar.01,2000 15:45:17

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

Name-Value Pair Arguments

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

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify the name and value pair arguments in any order as Name1,Value1,Name2,Value2.

expand all

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


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

expand all

addsampletocollectionAdd sample to tscollection
addtsAdd timeseries to tscollection
delsamplefromcollectionDelete sample from tscollection
horzcatHorizontally concatenate tscollection objects
removetsRemove timeseries from tscollection
resampleResample tscollection time vector
setSet tscollection properties
setabstimeSet tscollection times as date character vectors
settimeseriesnamesRename timeseries in tscollection
vertcatVertically concatenate tscollection objects
getQuery tscollection properties
getabstimeConvert tscollection time vector to cell array
getsampleusingtimeSubset of tscollection data
gettimeseriesnamesNames of timeseries in tscollection
isemptyDetermine if tscollection is empty
lengthLength of tscollection time vector
sizeSize of tscollection


collapse all

Create a tscollection object from two timeseries objects.

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

Time vector characteristics

      Start time            1 seconds
      End time              5 seconds

Member Time Series Objects:


Introduced before R2006a

Was this topic helpful?