Class Definition: timeseries

datatypes: timeseries

Array of samples indexed by time.

A timeseries object holds a sequence of samples, each taken at a time on a common time vector, together with the metadata that describes them: the units of the data and of the time, an optional absolute start date, the method of evaluating the series between samples, a quality code per sample, and named events.

Each sample may be a scalar, a vector, or an array. The time vector runs either down the first dimension of the data, each row being a sample, or along its last dimension, each slice being one; IsTimeFirst reports which, as the constructor describes.

timeseries is a value class: every method returns a modified copy and leaves its input unchanged. An array of timeseries objects is built by concatenation, as [ts1, ts2].

MATLAB recommends timetable for new code; timeseries is provided for code that exchanges it.

Property names are case-sensitive in dot indexing, as for every other class; MATLAB also reads ts.name for ts.Name. get and set accept any case.

See also: tscollection, timeseries2timetable, timetable, tsdata.timemetadata, tsdata.datametadata, tsdata.qualmetadata, tsdata.event, tsdata.interpolation

Source Code: timeseries

The timeseries class contains the following properties:

A vector of tsdata.event objects, or [] when there are none, by default.

A character vector, 'unnamed' by default, and '' for a series created with no argument. A string scalar is converted; any other value is refused, where MATLAB accepts it.

A numeric or logical array of any class, holding one sample per time and read against the time vector as the constructor describes: rows, or slices along the last dimension, with a matrix of as many columns as there are times stored as an Rx1xN array. Any other number of samples than there are times is refused, except while one of the two is empty, which lets a series be built by assigning Time and Data in turn.

A column vector of finite, non-decreasing times, in ts.TimeInfo.Units, counted from ts.TimeInfo.StartDate when that is set. Repeated times are allowed. An unsorted time vector is refused on assignment, since sorting it would move samples it was not given with. It is stored as double: MATLAB keeps an integer class, and then rounds new times to it.

Integers from -128 to 127, stored as double, [] by default. Either one code per sample, as a vector, or one per data element, as an array the size of Data. Their meaning is listed in QualityInfo.

true when each row of the data is a sample, false when the time vector runs along the last dimension of the data, as the constructor describes. It is kept when samples are selected, so a three-dimensional series cut to one sample holds a matrix with IsTimeFirst still false. Assigning the value it already has is accepted, and assigning the other is refused, since it would misalign the data with the time vector.

A logical scalar, true by default; 0 and 1 are converted.

The timeseries class offers the following public methods:

timeseries Create a ‘timeseries’ object.
get Return property values.
set Set property values.
getdatasamples Return the data of selected samples.
getdatasamplesize Return the size of one sample.
getsamples Return a series of selected samples.
getsampleusingtime Return a series of the samples at a time or between two times.
addsample Add samples to a series.
delsample Remove samples from a series.
append Join series end to end in time.
hasduplicatetimes True where a series repeats a time.
getabstime Return the dates of the samples as text.
setabstime Set the time vector of a series from dates.
setuniformtime Give a series a uniform time vector.
addevent Add events to a series.
delevent Remove events from a series.
gettsbeforeevent Return a series of the samples before the event.
gettsbeforeatevent Return a series of the samples before and at the event.
gettsatevent Return a series of the samples at the event.
gettsafteratevent Return a series of the samples at and after the event.
gettsafterevent Return a series of the samples after the event.
gettsbetweenevents Return a series of the samples between two events.
getinterpmethod Return the name of the interpolation method.
setinterpmethod Set the interpolation method.
resample Evaluate a series at new times.
synchronize Resample two series onto common times.
mean Return the mean of a series over time.
median Return the median of a series over time.
mode Return the mode of a series over time.
std Return the standard deviation of a series over time.
var Return the variance of a series over time.
sum Return the sum of a series over time.
min Return the minimum of a series over time.
max Return the maximum of a series over time.
iqr Return the interquartile range of a series over time.
getqualitydesc Return the description of each quality code.
plus The sum of series, ‘A + B’.
minus The difference of series, ‘A - B’.
times The element-wise product of series, ‘A .* B’.
mtimes The matrix product of series, ‘A * B’.
rdivide The element-wise quotient of series, ‘A ./ B’.
ldivide The element-wise left quotient, ‘A .\ B’.
mrdivide The matrix right division of series, ‘A / B’.
mldivide The matrix left division of series, ‘A \ B’.
eq True when two series are equal, ‘A == B’.
isequal True when two series are equal.
isequalwithequalnans True when two series are equal, ‘NaN’ equal to itself.
detrend Remove a polynomial trend from a series.
filter Filter a series.
idealfilter Filter a series with an ideal filter.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.
get Return property values.
set Set property values.