image thumbnail

Inverse distance weight function

version 1.1.0.0 (1.96 KB) by Andres Tovar
Inverse distance weight function to interpolate values based on the sampled points

1.2K Downloads

Updated 21 Nov 2016

View License

function Fint = idw(X0,F0,Xint,p,rad,L)
Inverse distance weight function to interpolate values based on
sampled points.

Fint = idw(X0,F0,Xint) uses input coordinates X0 and input values F0
where X0 is a N by M input matrix of N samples and M number of variables.
F0 is vector of N responses. Xint is a Q by M matrix of coordinates to be
interpolated. Fint is the vector of Q interpolated values.

Fint = idw(X0,F0,Xint,p,rad) uses the power p (default p = 2) and radius
rad (default rad = inf).

Fint = idw(X0,F0,Xint,p,rad,L) uses L-distance. By defaults L=2
(Euclidean norm).

Example:

X1 = [800;2250;3250;2250;900;500];
X2 = [3700;4200;5000;5700;5100;4900];
F = [13.84;12.15;12.87;12.68;14.41;14.59];
Q = 100;
[X1int,X2int] = meshgrid(0:4000/(Q-1):4000, 3200:(5700-3200)/(Q-1):5700);
Fint = idw([X1,X2],F,[X1int(:),X2int(:)]);
contourf(X1int, X2int, reshape(Fint,Q,Q), 20)

Contact info:

Andres Tovar
tovara@iupui.edu
Indiana University-Purdue University Indianapolis

Code developed for the course Design of Complex Mechanical Systems (ME
597) offered for the first time in Spring 2014

Cite As

Andres Tovar (2021). Inverse distance weight function (https://www.mathworks.com/matlabcentral/fileexchange/46350-inverse-distance-weight-function), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories

Community Treasure Hunt

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

Start Hunting!