timeseries
Creates a time series object: data samples with their times.
Category: Language Fundamentals > Data Types
Syntax
ts = timeseries(data)
Creates a series with sample times 0, 1, 2, ....
ts = timeseries(data, time)
Uses the given time vector.
ts = timeseries(___, 'Name', name)
Sets the name of the series.
Description
A timeseries keeps the values and their times together, and supports operations that respect time such as resample, addsample, delsample and synchronize. The sample count must match the length of the time vector; otherwise an error is raised.
Newer code often uses timetable, which also stores data with times but fits better with tables; use timeseries2timetable to convert.
Input arguments
data- Numeric array. One dimension must match the number of times (usually the first).
time- Vector of sample times, one per sample.
'Name'- Name of the series (default
'unnamed').
Output arguments
ts- timeseries object with properties
Data,Time,Name,Lengthand others.
Example
Data, time and name
ts = timeseries([10 20 30]', [0 1 2], 'Name', 'sig');
ts.Data'
ts.Time'
ts.Name
ts.Length
Output
ans = 1×3
10 20 30
ans = 1×3
0 1 2
ans = 'sig'
ans = 3
See also
timeseries2timetable timetable resample addsample tscollection