addsample

Adds samples to a timeseries object at given times.

Category: Language Fundamentals > Data Types

Syntax

ts = addsample(ts, 'Data', data, 'Time', time)

Inserts the values in data at the times in time, keeping the series ordered by time.

Description

The new samples are merged into the time vector in sorted order, so a sample added in the middle ends up between its neighbors. Adding a sample at a time that already exists is an error.

Input arguments

ts
A timeseries object.
'Data'
New values; must match the sample shape of the series.
'Time'
Times of the new samples.

Output arguments

ts
The time series with the extra samples.

Example

Insert a sample in the middle

ts = timeseries([10 20 30]', [0 1 2]);
ts = addsample(ts, 'Data', 25, 'Time', 1.5);
disp(ts.Time')
disp(ts.Data')
Output
         0    1.0000    1.5000    2.0000
    10    20    25    30

See also

timeseries addevent delsample resample