| MATLAB Function Reference | ![]() |
tsc = addsampletocollection(tsc,'time',Time,TS1Name,TS1Data,
TSnName,TSnData)
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.
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.
Note If a time-series member already has Quality values but you only provide data samples, 0s are added to the existing Quality array at the times given by Time. |
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.
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');Define a dictionary of quality codes and descriptions for ts2.
ts2.QualityInfo.Code = [0 1];
ts2.QualityInfo.Description = {'bad','good'};Assign a quality of code of 1, which is equivalent to 'good', to each data value in ts2.
ts2.Quality = ones(5,1);
Create a time-series collection tsc, which includes time series ts1 and ts2.
tsc = tscollection({ts1,ts2});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.
Note If you do not specify a quality code when adding a data sample to a time series that has quality codes, then the lowest quality code is assigned to the new sample by default. |
delsamplefromcollection, tscollection, tsprops
![]() | addsample | addtodate | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |