Inverse Distance Weighted (IDW) or Simple Moving Average (SMA) INTERPOLATION

This function computes at (Xi,Yi) unknown locations the IDW (w<0) or the SMA (w=0) predictions.
2,6K téléchargements
Mise à jour 10 mai 2010

Afficher la licence

This function computes at (Xi,Yi) unknown locations the IDW (w<0) or the SMA (w=0) predictions using r1 neighbourhood type ('n':number of points; 'r':radius) and r2 neighbourhood size from Vc measured values at (Xc,Yc) locations.

%% OUTPUTS
% Vi: (mandatory) [PxQ] gIDW interpolated values
% --> P=1, Q=1 yields interpolation at one
% point
% --> P>1, Q=1 yields interpolation at a
% vector of points
% --> P>1, Q>1 yields interpolation at a
% (ir)regular grid of points
%========================================

%% INPUTS
% Xc: (mandatory) [Nx1] x coordinates of known points
% Yc: (mandatory) [Nx1] y coordinates of known points
% Vc: (mandatory) [Nx1] known values at [Xc, Yc] locations
% Xi: (mandatory) [PxQ] x coordinates of points to be interpolated
% Yi: (mandatory) [PxQ] y coordinates of points to be interpolated
% w: (mandatory) [scalar] distance weight
% --> w<0, for Inverse Distance Weighted
% interpolation [IDW]
% --> w=0, for Simple Moving Average (only
% if neighorhood size is local and not
% global) [SMA]
% r1: (optional) [string] neighbourhood type
% --> 'n' (default) number of neighbours
% --> 'r' fixed radius length
% r2: (optional) [scalar] neighbourhood size
% --> number of neighbours, if r1=='n'
% default is length(Xc)
% --> radius length, if r1=='r'
% default is largest distance between known points
%========================================

%% SYNTAX
% --- IDW ---
% all inputs:
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,-2,'n',30);
% 6 inputs:
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,-2);
% --> r1='n'; r2=length(Xc);
% 7 inputs:
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,-2,'n');
% --> r2=length(Xc);
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,-2,'r');
% --> r2=largest distance between know points [Xi,Yi] (see D1 calculation)
% --- SMA ---
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,0,'n',10);
% --- Spatial Map ---
% Vi = gIDW(Xc,Yc,Vc,Xi,Yi,-2,'n',10);
% -with Xi and Yi 2D arrays of coordinates relative to an (ir)regular
% grid.
%========================================

%% EXAMPLES
% Interpolation at one point location:
% Vi = gIDW([1:1:10]',[2:2:20]',rand(10,1)*100,5.5,11,-2,'n');
% ---
% Interpolation at a regular grid of unknown points:
% XYc = [1:1:10]';
% Vc = rand(10,1)*100;
% Xi = rand(50,50)*10;
% Yi = rand(50,50)*10;
% [Xi,Yi] = meshgrid(XYc);
% Vi = gIDW(XYc,XYc,Vc,Xi,Yi,-2,'r',3);
% hold on
% mapshow(Xi,Yi,Vi,'DisplayType','surface')
% colormap gray
% scatter(XYc,XYc,Vc,'filled','MarkerFaceColor','g','MarkerEdgeColor','y')
% axis([0,11,0,11])
% hold off

Citation pour cette source

Giuliano Langella (2024). Inverse Distance Weighted (IDW) or Simple Moving Average (SMA) INTERPOLATION (https://www.mathworks.com/matlabcentral/fileexchange/27562-inverse-distance-weighted-idw-or-simple-moving-average-sma-interpolation), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2008b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Optimization Toolbox dans Help Center et MATLAB Answers
Remerciements

Inspiré par : Inverse Distance Weight

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0.0