Inverse distance weight function
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 (2024). Inverse distance weight function (https://www.mathworks.com/matlabcentral/fileexchange/46350-inverse-distance-weight-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Interpolation >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.