extract
Extract a sub-sample of data from a vector or matrix.
Syntax
X = extract(x,fs,tst,ted) % Matlab & Octave X <- extract(x,fs,tst,ted) #R
Description
Extract a sub-sample of data from a vector or matrix.
Inputs
Input var | Description | Units | Default value |
---|---|---|---|
x | is a vector or matrix of measurements. If x is a matrix, each column is treated as a separate measurement vector. | N/A | N/A |
fs | is the sampling rate in Hz of the data in x. | Hz | N/A |
tst | defines the start time in seconds of the interval to be extracted from x. | seconds | N/A |
ted | defines the end time in seconds of the interval to be extracted from x. | seconds | N/A |
Outputs
Output var | Description | Units |
---|---|---|
X | is a matrix containing a sub-sample of x. X has the same number of columns as x. The length of the sub-sample will be round(fs*(tend-tstart)) samples. | N/A |
Notes & assumptions
- Output sampling rate is the same as the input sampling rate.
- If either tstart or tend are beyond the length of x, non-existing samples will be replaced with NaN in X.
Example
Matlab & Octave
The example below uses data from the file testset3.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset1 = load_nc(‘testset1.nc’)
extract(testset1.A.data, testset1.A.sampling_rate, 3, 100)
R
The example below uses data from the file testset3.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:
testset1 <- load_nc(‘testset1.nc’)
extract(x = testset1$A$data, fs = testset1$A$sampling_rate, tst = 3, ted = 100)
About
bugs@animaltags.org Last modified: 10 May 2017