Question

I have a 3D volume (80x80x3 points) of measurement values ([646 2] values and timepoints). This data is not ordered and time between sample timepoints is non-equidistant. I would like to resample/interpolate to have less timepoints (say [0:0.1:1] spacing). All the data together becomes an [80 80 3 646 2] array where [: : : : 2] is time, which I would like to interpolate to.

My first try was with interp1 but the responses below already helped me further and now the problem Im not sure about yet is how to interpolate to time when its kind of sharing its dimension with measurement value? What I mean is [: : : : 1] are the values and [: : : : 2] are the timepoints.

Was it helpful?

Solution

 % suppose your original matrix ranges from 1:80,1:80,1:3,1:646
 [x,y,z,t] = ndgrid(1:1:80,1:1:80,1:1:3,1:646);   

 % and you want to interpolate in finer constructed grids with interval of 0.1
 [xi,yi,zi,ti] = ndgrid(1:0.1:80,1:0.1:80,1:0.1:3,1:0.1:646);

 % v is your original matrix measurement matrix, vi is the interpolation
 vi = interpn(x,y,z,t,v,xi,yi,zi,ti,'spline');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top