timeseries - Create timeseries object

Syntax

ts = timeseries
ts = timeseries(Data)
ts = timeseries(Name)
ts = timeseries(Data,Time)
ts = timeseries(Data,Time,Quality)
ts = timeseries(Data,...,'Parameter',Value,...)

Description

ts = timeseries creates an empty time-series object.

ts = timeseries(Data) creates a time series with the specified Data.
ts has a default time vector that ranges from 0 to N-1 with a 1-second interval, where N is the number of samples. The default name of the timeseries object is 'unnamed'.

ts = timeseries(Name) creates an empty time series with the name specified by a string Name. This name can differ from the time-series variable name.

ts = timeseries(Data,Time) creates a time series with the specified Data array and Time. When time values are date strings, you must specify Time as a cell array of date strings.

ts = timeseries(Data,Time,Quality) creates a timeseries object. The Quality attribute is an integer vector with values-128 to 127 that specifies the quality in terms of codes defined by QualityInfo.Code.

ts = timeseries(Data,...,'Parameter',Value,...) creates a timeseries object with optional parameter-value pairs after the Data, Time, and Quality arguments. You can specify the following parameters:

Remarks

Definition: timeseries

The time-series object, called timeseries, is a MATLAB variable that contains time-indexed data and properties in a single, coherent structure. For example, in addition to data and time values, you can also use the time-series object to store events, descriptive information about data and time, data quality, and the interpolation method.

Definition: Data Sample

A time-series data sample consists of one or more values recorded at a specific time. The number of data samples in a time series is the same as the length of the time vector.

For example, suppose that ts.data has the size 5-by-4-by-3 and the time vector has the length 5. Then, the number of samples is 5 and the total number of data values is 5 x 4 x 3 = 60.

Notes About Quality

When Quality is a vector, it must have the same length as the time vector. In this case, each Quality value applies to the corresponding data sample. When Quality is an array, it must have the same size as the data array. In this case, each Quality value applies to the corresponding data value of the ts.data array.

Examples

Example 1 — Using Default Time Vector

Create a timeseries object called 'LaunchData' that contains four data sets, each stored as a column of length 5 and using the default time vector:

b = timeseries(rand(5, 4),'Name','LaunchData')

Example 2 — Using Uniform Time Vector

Create a timeseries object containing a single data set of length 5 and a time vector starting at 1 and ending at 5:

b = timeseries(rand(5,1),[1 2 3 4 5])

Example 3

Create a timeseries object called 'FinancialData' containing five data points at a single time point:

b = timeseries(rand(1,5),1,'Name','FinancialData')

See Also

addsample, tscollection, tsdata.event, tsprops

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS