MATLAB: How tonterpolate *between* 2D matrices

interpolationmatrices

I think this is an easy question, but my attempts so far have been frustrated. I have a series of 2D (1300×1500) regularly spaced matrices (basically change over time). I want to interpolate between these to create additional 2D matrices that will be intermediates between the others. I am sure that griddata3 should be able to do this, but I can't get it to work.

Best Answer

Are you only doing interpolation along the time dimension? I think you should be able to use interp1.
Assuming you have N time slices, then you can first concatenate the arrays you have, then permute (because interp1 has to have interpolated dimension first), then interpolate:
% Your 2D arrays:
x1 = [1 2; 3 4];
x2 = [2 3; 4 5];
% Concatenate:
x = cat(3,x1,x2);
% Permute to get interpolated dimension first:
x = permute(x,[3 1 2])
% Define arbitrary unit for time slices:
t0 = [1 2];
% Interpolate to time slice at t=1.5:
x_interp = interp1(t0,x,1.5)
I see that your input 2D arrays are quite large, so you may need to do this in chunks.
[griddata3 is a deprecated function, and you probably don't want to use it.]
Related Question