Borrar filtros
Borrar filtros

How to resample a timeseries to unique interval?

1 visualización (últimos 30 días)
Bedanta
Bedanta el 13 de Sept. de 2012
I have a file which contains the following information in its columns: YYYY MM DD H MIN S X Y Z
The time increment is in seconds, but the interval is not constant. Sometimes it is 3s and sometimes 2s and occassionally 10s.
Can I use some command to have a matrix with constant time intervals and all other values interpolated (in case they are missing)?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Sept. de 2012
Editada: Azzi Abdelmalek el 13 de Sept. de 2012
my=cellstr(datestr(datenum(2010,1,1,1,1,(1:24*1)),'yy/mm/dd HH:MM:SS'))
%my is your date cell array
time_v=datevec(my);n=size(time_v,1);
x=rand(n,1); % example: x y z your data
y=rand(n,1);
z=rand(n,1);
du=etime(time_v(end,:),
time_v(1,:))
i_s=time_v(1,6);
y0=time_v(1,1);
m0=time_v(1,2);
d0=time_v(1,3);
h0=time_v(1,4);
min0=time_v(1,5);
new_time=datevec(datestr(datenum(y0,m0,d0,h0,min0,(i_s:i_s+du)),'yy/mm/dd HH:MM:SS'))
method='linear'
newt=new_time(:,6);
t=time_v(:,6);
new_x=interp1(t,x,newt,method)
new_y=interp1(t,y,newt,method)
new_z=interp1(t,z,newt,method)
  1 comentario
Bedanta
Bedanta el 14 de Sept. de 2012
I think it gives me a head start to how I should approach, but is not really the answer that I was looking. I forgot to mention that the increment I am seeking is constant 2s. I should hopefully be able to work it out from here. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by