inverse distance interpolation

7 vues (au cours des 30 derniers jours)
Jakob
Jakob le 12 Jan 2012
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(2x7381,2x7381,1x7381), 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!

Réponse acceptée

Walter Roberson
Walter Roberson le 12 Jan 2012
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)

Plus de réponses (2)

Jakob
Jakob le 13 Jan 2012
I am working on a sphere but the matrices contain a 2-dimensional grid, so I don't think I should have three rows. I transposed the matrices since the description indeed rather sounds like 7381x2 and now I don't get an error but it takes forever to calculate. So I tried the same with very small test matrices, but then I get back "Index exceeds matrix dimension". However, this error appears some lines further than the previous one, so it seems as if I this point has been solved.

Jakob
Jakob le 13 Jan 2012
It actually worked! I though this was a very bad sign that it took so long to calculate but after I let it running over night I actually got what I wanted. So the right step was indeed to transpose the matrices, just as you suggested.
Thank you very much!

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by