MATLAB: Interpolating a 3D Matrix using interp1

interp1

I have a 14x14x221 matrix, A. Using a loop over the third dimension, I'm trying to interpolate the 14×14 matrix at each iteration of this loop to produce a new matrix that has more data points. Then save the new matrix at each iteration to form a new 3D matrix that has X,Y dimensions much greater than 14.
My question is how to use interp1 to spline the 14×14 matrix using the third dimension of the 14x14x221 matrix.

Best Answer

A = rand(14,14,221) ;
% interpolation along row
N = 100 ;
[m,n,p] = size(A) ;
iwant = zeros(m,N,p) ;
xi = linspace(1,n,N) ;
for i = 1:m
for j = 1:p
T = interp1(1:n,A(i,:,j),xi) ;
iwant(i,:,j) = T ;
end
end
A = iwant ;
Repeat the same along columns.