Documentation Center

  • Trial Software
  • Product Updates

addsample

Class: timeseries

Add data sample to timeseries object

Syntax

ts1 = addsample(ts, s)
ts1 = addsample(ts, 'Data', data-value, 'Time',time-value,..., Name,Value)

Description

ts1 = addsample(ts, s) adds one or more new data samples stored in a structure s to the timeseries object ts.

ts1 = addsample(ts, 'Data', data-value, 'Time',time-value,..., Name,Value) adds one or more data samples to the timeseries object ts along with additional options specified by one or more Name,Value pair arguments.

Tips

  • If N is the number of data samples, you can get the sample size of each time with SampleSize = getsamplesize(ts).

    When ts.IsTimeFirst is true, the size of the data is N-by-SampleSize. When ts.IsTimeFirst is false, the size of the data is SampleSize-by-N.

Input Arguments

s

A structure that you must define before passing as an argument to addsample. It consists of the following optional fields:

  • s.data

  • s.time

  • s.quality

  • s.overwriteflag

data-value

A numeric data value.

time-value

A valid time vector.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Quality'

Array of data quality codes.

Default: []

'OverwriteFlag'

Logical value that controls whether to overwrite a data sample at the same time with the new sample you are adding to your timeseries object. When set to true, the new sample overwrites the old sample at the same time.

Default: false

Output Arguments

ts1

The timeseries object that results when you add the specified samples to the original timeseries object.

Definitions

data sample

One or more values recorded at a specific time. The number of data samples in a time series is the same as the length of the time vector.

Examples

Add a data value of 420 at time 3:

ts = ts.addsample('Time',3,'Data',420);
 

Add a data value of 420 at time 3 and specify quality code 1 for this data value. Set the OverwriteFlag to overwrite an existing value at time 3.

ts = ts.addsample('Data',3.2,'Quality',1,'OverwriteFlag',... 
        true,'Time',3);

See Also

| |

Was this topic helpful?