资源简介
matlab编写的插值函数,反距离插值较其他方法真实,适用性强
代码片段和文件信息
function [Vint]=IDW(original_xvectororiginal_yvectororiginal_zvectorinterpolated_xvectorinterpolated_yvectordistance_weightmoderadius_lenght)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%***************************************
%% INVERSE DISTANCE WEIGHT **
%%***************************************
%******INPUTS***********
%original_xvector = stations x coordinates (columns) [vector]
%original_yvector = stations y coordinates (rows) [vector]
%original_zvector = variable values on the point [original_xvector original_yvector]
%interpolated_xvector = interpolation points interpolated_xvector coordinates [vector]
%interpolated_yvector = interpolation points interpolated_yvector coordinates [vector]
%distance_weight = distance weight form -2/3 to -5/3 but not large 2 (very important)
% mode should be: ‘fr‘ : fixed radius or ‘ng‘ : neighbours
%radius_lenght --- radius lenght
%%% OUTPUTS
%Vint --- Matrix [length(interpolated_yvector)length(interpolated_xvector)] with interpolated variable values
%
%******************************EXAMPLES
%%% V_spa=IDW(x1y1v1xy-2‘ng‘length(x1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Yang CS -- ycsgps@163.com
% Copyright 2009
% $Date: 2009/08/02 $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vint=zeros(length(interpolated_yvector)length(interpolated_xvector));
original_xvector=reshape(original_xvector1length(original_xvector));
original_yvector=reshape(original_yvector1length(original_yvector));
original_zvector=reshape(original_zvector1length(original_zvector));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if strcmp(mode‘fr‘)
for i=1:length(interpolated_xvector)
for j=1:length(interpolated_yvector)
D=[]; V=[]; wV =[]; vcc=[];
D= sqrt((interpolated_xvector(i)-original_xvector).^2 +(interpolated_yvector(j)-original_yvector).^2);
D=D(D V = vcc.*(D.^distance_weight);
wV = D.^distance_weight;
if isempty(D)
V=NaN;
else
V=sum(V)/sum(wV);
end
Vint(ji)=V;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
else
if (radius_lenght > length(original_zvector)) || (radius_lenght<1)
disp(‘Error: Number of neighbours not sufficient‘)
end
for i=1:length(interpolated_xvector)
for j=1:length(interpolated_yvector)
D=[]; V=[]; wV =[];vcc=[];
D= sqrt((interpolated_xvector(i)-original_xvector).^2 +(interpolated_yvector(j)-original_yvector).^2);
[DI]=sort(D);
vcc=original_zvector(I);
V = vcc(1:radius_lenght).*(D(1:radius_lenght).^distance_weight);
wV = D(1:radius_lenght).^distance_weight;
V=sum(V)/sum(wV);
Vint(ji)=V;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3078 2009-08-02 22:37 IDW.m
----------- --------- ---------- ----- ----
3078 1
- 上一篇:基于卡尔曼滤波的视频人脸跟踪MATLAB源码
- 下一篇:马氏链模型 matlab
评论
共有 条评论