MATLAB: Inverse distance interpolation

invdisti.minverse distance interpolationmatrix dimensions must agree

Hey there, I am trying to use an inverse distance interpolation using invdisti.m. I can't find it in the Matlab database but it seems to be commonly used since I find it on many other pages.
This is the files header:
function fi = invdisti(R,Ri,f,opt)
% INVDISTI Inverse distance interpolation.
% FI = INVDISTI(R,RI,F) Interpolates multi-
% dimensional set with coordinates R (N by D)
% where N is the number of points and D -
% dimension and values F to points with
% coordinates RI.
% Returns interpolated values FI at points RI.
%

% FI = INVDISTI(R,RI,F,W) allows also W -
% vector of coefficients (relative weights)
% for combining results from interpolation
% with different power law in the form:
% FI = F1*W1+F2*W2+ ..., where F_i - estimates
% of interpolation with weiths proportional to
% R^(-D-i), (D - dimension).
% Default W = 3 which is equivalent to W=[1 1 1]
% is an equal-weight combination of estimates
% from R^(-D-1), R^(-D-2), R^(-D-3) laws.
%
% Uses inverse distance interpolation method.
% Copyright (c) 1995 by Kirill K. Pankratov
% kirill@plume.mit.edu
% 05/20/95
In my case I have the following argument dimensions: X=invdisti(2×7381,2×7381,1×7381), where the first matrix is a regular pattern on a sphere, the second one random points on a spehere and the third one values according to the points specified in the first one. However, I get this error "Error using '*'. Inner matrix dimensions must agree" from invdisti.m. Does anyone see how my way is not according to the files header? Thank you!

Best Answer

It looks to me as if likely F should contain N values (2 in your case).
As you are operating on a sphere, it sounds like you would more likely want
invdisti(7381x3, 7381x3, 7381x1)