Converting/resampling 10-min interval timseries data to 15-min

7 views (last 30 days)
Hello
I have time series data taken at 10-min intervals (see below). I would like to somehow obtain values at 15-min intervals from this data.
(% Y M D H MI S VAL)
2008 1 1 0 0 0 1.68400000000000
2008 1 1 0 10 0 1.71400000000000
2008 1 1 0 20 0 1.74400000000000
2008 1 1 0 30 0 1.77300000000000
2008 1 1 0 40 0 1.80300000000000
2008 1 1 0 50 0 1.83400000000000
2008 1 1 1 0 0 1.86500000000000
2008 1 1 1 10 0 1.89800000000000
2008 1 1 1 20 0 1.93400000000000
2008 1 1 1 30 0 1.97200000000000
2008 1 1 1 40 0 2.01200000000000
2008 1 1 1 50 0 2.05500000000000
I have tried using the resample function as follows:
ts2 = timeseries(val);
val_int = resample(ts2, 0:15/24/60:718); %%(There are 719 values in the original timeseries)
...This really doesn't work very well!
Is resample the right tool to use? If not, could somebody please give any hints? I was thinking of maybe some sort of moving average?
Many thanks in advance
Ozgun

Accepted Answer

Star Strider
Star Strider on 21 Jun 2014
Edited: Star Strider on 21 Jun 2014
I’m not clear on what you are doing. You seem to be creating a timeseries object using only one of your variables, VAL. I do not have much recent experience with timeseries objects, so I did the interpolation on your data (that I call Mtx) with interp1:
Mtx = [2008 1 1 0 0 0 1.68400000000000
2008 1 1 0 10 0 1.71400000000000
2008 1 1 0 20 0 1.74400000000000
2008 1 1 0 30 0 1.77300000000000
2008 1 1 0 40 0 1.80300000000000
2008 1 1 0 50 0 1.83400000000000
2008 1 1 1 0 0 1.86500000000000
2008 1 1 1 10 0 1.89800000000000
2008 1 1 1 20 0 1.93400000000000
2008 1 1 1 30 0 1.97200000000000
2008 1 1 1 40 0 2.01200000000000
2008 1 1 1 50 0 2.05500000000000];
Mtx1 = [datenum(Mtx(:,1:6)) Mtx(:,7)];
Min15 = 1/(24*4); % Four 15-min segments/hour; here, fractions of a day
TIntrpVal = [Mtx1(1,1):Min15:Mtx1(end,1)];
Mtx2 = interp1(Mtx1(:,1),Mtx1,TIntrpVal);
TestMtx2 = [datevec(Mtx2(:,1) ) Mtx2(:,2)] % Test to be sure it works
produces:
TestMtx2 =
2008 1 1 0 0 0 1.684
2008 1 1 0 15 0 1.729
2008 1 1 0 30 0 1.773
2008 1 1 0 45 0 1.819
2008 1 1 1 0 0 1.865
2008 1 1 1 15 0 1.916
2008 1 1 1 30 0 1.972
2008 1 1 1 45 0 2.033
Does that do what you want?
  4 Comments
Stefan Kermer
Stefan Kermer on 18 Feb 2016
Hi there,
it is astonishing, that with 5 lines of code you produce such a nice result. Nevertheless it produces wrong results.
Can someone help me to make little adaptions of that code to get it right?
... As the original data is in 10 minutes resolution and the target resolution is a 15 minutes interval it is not correct to interpolate linear...
A correct interpolation function would need to implement a weight with 2/3 first 10 minutes and 1/3 second 10 minutes for the first 15 minutes.. and so forth Do you know what I mean?
Stefan
Stefan Kermer
Stefan Kermer on 19 Feb 2016
Hi guys,
found the right code...
Matlab is amazing
W_10 = (1:52560)'; % Dummy-Daten
n_10 = length(W_10);
n_15 = n_10 * 2 / 3;
W_15(1:2:n_15) = (W_10(1:3:n_10) * 2 + W_10(2:3:n_10)) / 3;
W_15(2:2:n_15) = (W_10(2:3:n_10) + W_10(3:3:n_10) * 2) / 3;

Sign in to comment.

More Answers (0)

Categories

Find more on Time Series in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!