addsampletocollection - Add sample to tscollection object

Syntax

tsc = addsampletocollection(tsc,'time',Time,TS1Name,TS1Data, TSnName,TSnData)

Description

tsc = addsampletocollection(tsc,'time',Time,TS1Name,TS1Data, TSnName,TSnData) adds data samples TSnData to the collection member TSnName in the tscollection object tsc at one or more Time values. Here, TSnName is the string that represents the name of a time series in tsc, and TSnData is an array containing data samples.

Remarks

If you do not specify data samples for a time-series member in tsc, that time-series member will contain missing data at the times given by Time (for numerical time-series data), NaN values, or (for logical time-series data) false values.

When a time-series member requires Quality values, you can specify data quality codes together with the data samples by using the following syntax:

tsc = addsampletocollection(tsc,'time',time,TS1Name,... 
         ts1cellarray,TS2Name,ts2cellarray,...)

Specify data in the first cell array element and Quality in the second cell array element.

Examples

The following example shows how to create a tscollection that consists of two timeseries objects, where one timeseries does not have quality codes and the other does. The final step of the example adds a sample to the tscollection.

  1. Create two timeseries objects, ts1 and ts2.

    ts1 = timeseries([1.1 2.9 3.7 4.0 3.0],1:5,...
                   'name','acceleration');
    ts2 = timeseries([3.2 4.2 6.2 8.5 1.1],1:5,...
                   'name','speed');
  2. Define a dictionary of quality codes and descriptions for ts2.

    ts2.QualityInfo.Code = [0 1];
    ts2.QualityInfo.Description = {'bad','good'};
  3. Assign a quality of code of 1, which is equivalent to 'good', to each data value in ts2.

    ts2.Quality = ones(5,1);
  4. Create a time-series collection tsc, which includes time series ts1 and ts2.

    tsc = tscollection({ts1,ts2});
  5. Add a data sample to the collection tsc at 3.5 seconds.

    tsc = addsampletocollection(tsc,'time',3.5,'acceleration',10, 
            'speed',{5 1});

    The cell array for the timeseries object 'speed' specifies both the data value 5 and the quality code 1.

See Also

delsamplefromcollection, tscollection, tsprops

  


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