How to resample a timeseries to unique interval?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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)?
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 13 Sep 2012
Modifié(e) : Azzi Abdelmalek
le 13 Sep 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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!