interpolate data every 5 minutes in matlab

Assuming you have a time series data y with timestamps t, follow the steps below to interpolate data every 5 minutes:

  1. Convert t to a datetime array:
main.m
t = datetime(t,'ConvertFrom','datenum');
41 chars
2 lines
  1. Create a new time array with datetime interval of 5 minutes:
main.m
t_new = t(1):minutes(5):t(end);
32 chars
2 lines
  1. Interpolate the data to new time array:
main.m
y_new = interp1(t,y,t_new);
28 chars
2 lines

Here, interp1 is used for 1-D interpolation of y to t_new.

Your interpolated data is now available in y_new variable.

related categories

gistlibby LogSnag