addsample
Add data sample to timeseries
object
Syntax
Description
tsout = addsample(
specifies
additional information for adding data samples using one or more name-value
pairs.tsin
,'Data'
,datavals
,'Time'
,timevals
,Name,Value
)
Examples
Add Data Samples
Add and change data in a timeseries
object.
Create a timeseries
object ts1
and display the data and time samples.
ts1 = timeseries((0:10:50)',(0:5)'); ts1.Data
ans = 6×1
0
10
20
30
40
50
ts1.Time
ans = 6×1
0
1
2
3
4
5
Add a data sample to the end of ts1
.
ts2 = addsample(ts1,'Data',60,'Time',6); ts2.Data
ans = 7×1
0
10
20
30
40
50
60
ts2.Time
ans = 7×1
0
1
2
3
4
5
6
Change the last data sample in ts2
from 60 to 100.
ts3 = addsample(ts2,'Data',100,'Time',6,'OverwriteFlag',true); ts3.Data
ans = 7×1
0
10
20
30
40
50
100
Input Arguments
tsin
— Input timeseries
scalar
Input timeseries
, specified as a scalar.
datavals
— Sample data
scalar | vector | multidimensional array
Sample data, specified as a numeric or logical
scalar,
vector, or multidimensional array.
Data Types: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
timevals
— Sample times
scalar | vector
Sample times, specified as a numeric scalar or vector, or a cell array of date character vectors. Valid date character vectors and strings can have the following forms:
Format | Example |
---|---|
dd-mmm-yyyy
HH:MM:SS | 01-Mar-2000 15:45:17 |
dd-mmm-yyyy | 01-Mar-2000 |
mm/dd/yy | 03/01/00 |
mm/dd | 03/01 |
HH:MM:SS | 15:45:17 |
HH:MM:SS PM | 3:45:17 PM |
HH:MM | 15:45 |
HH:MM PM | 3:45 PM |
mmm.dd,yyyy
HH:MM:SS | Mar.01,2000 15:45:17 |
mmm.dd,yyyy | Mar.01,2000 |
mm/dd/yyyy | 03/01/2000 |
Data Types: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| cell
s
— Sample structure
scalar
Sample structure, specified as a scalar of type struct
with the following optional fields:
s.data
— Numeric array of datas.time
— Numeric time vector or cell array of valid date character vectors or stringss.quality
— Integer array of quality codes from -128 to 127s.overwriteflag
— Overwrite indicator specified astrue
to overwrite existing data samples with the added samples
Data Types: struct
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: tsout =
addsample(tsin,'Data',5,'Time',3,'OverwriteFlag',true)
Quality
— Quality codes
[]
(default) | scalar | vector | multidimensional array
Quality codes, specified as []
or a scalar, vector,
or multidimensional array of integers ranging from -128 to 127.
When the quality code value is a vector, it must have the same length as the time vector. Each element applies to the corresponding data sample.
When the quality code value is an array, it must have the same size as the data array. Each element applies to the corresponding element of the data array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
OverwriteFlag
— Overwrite indicator
false
(default) | true
Overwrite indicator, specified as a logical value that controls
whether to overwrite data samples that have the same associated time as
the added samples. true
indicates the added data
overwrites the previous data, while false
adds the
sample resulting in a repeated time value.
Data Types: logical
Version History
Introduced before R2006a
See Also
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)