addsampletocollection

Adds samples at given times to every member of a tscollection.

Category: Language Fundamentals > Data Types

Syntax

tc = addsampletocollection(tc, 'Time', t, name, data)

Inserts a sample at time t, with the value data for the member called name.

Description

All members of a tscollection share one time vector, so a new time extends every member. This function does that in one step and fills the members you do not mention with NaN.

Input arguments

tc
A tscollection object.
'Time'
Time or vector of times of the new samples.
name, data
Member name and its new values. Members not listed receive missing values (NaN).

Output arguments

tc
The updated collection with a longer common time vector.

Example

Extend a collection

tc = tscollection(timeseries([1 2 3]', [0 1 2], 'Name', 'a'));
tc = addsampletocollection(tc, 'Time', 3, 'a', 9);
disp(tc.Time')
disp(tc.a.Data')
Output
     0     1     2     3
     1     2     3     9

See also

tscollection addts addsample timeseries