How to resample a timeseries to unique interval?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2012-9-13
编辑:Azzi Abdelmalek
2012-9-13
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)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!