Subset a time-series using matlab -
Subset a time-series using matlab -
i have 1 min interval time series want subset 3 columns of data. time format dd/mm/yy hh:mm:ss want specify 20 min time value want extract corresponding samples corresponding days (19:00 ; 19:20 ; 19:40 ; 20:00).
i created time series using ts = timeseries(data, time) samples=getdatasamples(ts, i)
but having problem defining logical vector can such extraction
please seek code:
pat_19='19:[0 2 4]0:00'; pat_20='20:00:00'; out_19=~(cellfun('isempty',regexpi(a(:,1),pat_19,'match'))); out_20=~(cellfun('isempty',regexpi(a(:,1),pat_20,'match'))); out=a(find(out_19+out_20),:); here, assumed value of seconds '0'
please see illustration below:
"a" cell array date first column , info values of time series.
a = '15/08/81 19:00:00' 0.01 '15/08/81 19:10:00' 0.02 '15/08/81 19:20:00' 0.03 '15/08/81 19:30:00' 0.04 '15/08/81 19:40:00' 0.06 '15/08/81 19:50:00' 0.07 '15/08/81 20:00:00' 0.01 '15/08/81 20:10:00' 0.02 '15/08/81 20:20:00' 0.03 '15/08/81 20:30:00' 0.03 after executing above code, output stored in cell array "out"
out = '15/08/81 19:00:00' 0.01 '15/08/81 19:20:00' 0.03 '15/08/81 19:40:00' 0.06 '15/08/81 20:00:00' 0.01 matlab time-series
Comments
Post a Comment