Irregular time series data interpolation

1 visualización (últimos 30 días)
Andiyu
Andiyu el 6 de Dic. de 2013
Comentada: ceb el 7 de Mzo. de 2015
Hi all,
I have a time series data: (date, time, tide height)
11/4/2013 2:49 0.39
11/4/2013 8:59 -0.39
11/4/2013 15:12 0.4
etc.
How to interpolate the data so I can get tide height values with interval of 10 minutes?
Thanks Andi

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 6 de Dic. de 2013
Editada: Andrei Bobrov el 6 de Dic. de 2013
f = fopen('yourdata.txt');
c = textscan(f,'%s %s %f');
fclose(f);
DT = datenum(strcat(c{1:2}),'mm/dd/yyyyHH:MM');
dt = 1/24/6; % (10 minites)/day'
p = ceil(DT(1)/dt);
[y,m,d,h,mm] = datevec(p*dt);
dn = datenum(y,m,d,h,mm+10*(0:floor(DT(end)/dt) - p)');
dv = datevec(dn);
out = [dv(:,1:5),interp1(DT,c{3},dn)];
  3 comentarios
Andiyu
Andiyu el 11 de Dic. de 2013
solved the problem
f = fopen('data.txt');
c = textscan(f,'%s %s %f');
fclose(f);
DT = datenum(strcat(c{1:2}),'dd/mm/yyyyHH:MM');
dt = 1/24/6; % (10 minites)/day'
p = ceil(DT(1)/dt);
[y,m,d,h,mm,ss] = datevec(p*dt);
dn = datenum(y,m,d,h,mm+10*(0:floor(DT(end)/dt) - p)',ss);
dv = datevec(dn);
out = [dv(:,1:5),interp1(DT,c{3},dn)];
ceb
ceb el 7 de Mzo. de 2015
Hi Andrei and or Andiyu, It's an older thread but if you are still around... I was looking to do basically the same thing as Andiyu except interpolate 1 minute data from 10 minute data. I was able to adjust your above code to get (almost) what I am after but changing the following line: dn = datenum(y,m,d,h,mm+10*(0:floor(DT(end)/dt) - p)',ss); to dn = datenum(y,m,d,h,mm+1*(0:floor(DT(end)/dt) - p)',ss);
BUT the output is only as many rows as the original data - meaning I am still missing interpolated data. Original data is from 5/2/2015 to 26/2/2015 but results only go from 5/2/2015 to 7/2/2015. I am not sure what else in the code needs to be changed... Any suggestions? Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by