基于matlab的散射数据反距离加权插值

基于matlab的散射数据反距离加权插值,matlab,text,multidimensional-array,interpolation,Matlab,Text,Multidimensional Array,Interpolation,我想在我的数据集上使用IDW插值技术。像往常一样,包含在文本文件中。名称Output_00.text到文件夹中的Output_23.text 每个文本文件由三列组成纬度、经度和温度值。第三列(温度列)包含-9999.000值,编码为缺失值或NaN值 我想通过反距离加权插值技术对温度中的NaN/缺失值进行插值 这是我正在尝试的,但不知道如何使用它 function[Vint]=IDW(xc,yc,vc,x,y,e,r1,r2) %%% INPUTS %xc = stations x coordi

我想在我的数据集上使用IDW插值技术。像往常一样,包含在文本文件中。名称
Output_00.text
到文件夹中的
Output_23.text

每个文本文件由三列组成<代码>纬度、
经度
温度
值。第三列(温度列)包含-9999.000值,编码为缺失值或NaN值

我想通过反距离加权插值技术对温度中的NaN/缺失值进行插值

这是我正在尝试的,但不知道如何使用它

function[Vint]=IDW(xc,yc,vc,x,y,e,r1,r2)

%%% INPUTS
%xc = stations x coordinates (columns) [vector]
%yc = stations y coordinates (rows) [vector]
%vc = variable values on the point [xc yc]
%x = interpolation points  x coordinates [vector]
%y = interpolation points y coordinates [vector]
%e = distance weight
%r1 --- 'fr' = fixed radius ;  'ng' = neighbours
%r2 --- radius lenght if r1 == 'fr' / number of neighbours if  r1 =='ng'
%%% OUTPUTS
%Vint --- Matrix [length(y),length(x)] with interpolated  variable values
%%% EXAMPLES
%%% --> V_spa=IDW(x1,y1,v1,x,y,-2,'ng',length(x1));

%   Simone Fatichi -- simonef@dicea.unifi.it
%   Copyright 2009
%   $Date: 2009/06/19 $ 
%   $Updated 2012/02/24 $ 

Vint=zeros(length(y),length(x));
xc=reshape(xc,1,length(xc));
yc=reshape(yc,1,length(yc));
vc=reshape(vc,1,length(vc));

if  strcmp(r1,'fr')
    if  (r2<=0)
        disp('Error: Radius must be positive')
        return
    end
    for i=1:length(x)
        for j=1:length(y)
            D=[]; V=[]; wV =[]; vcc=[];
            D= sqrt((x(i)-xc).^2 +(y(j)-yc).^2);
            if min(D)==0
                disp('Error: One or more stations have the coordinates of an interpolation point')
                return
            end
            vcc=vc(D<r2); D=D(D<r2); 
            V = vcc.*(D.^e);
            wV = D.^e;
            if isempty(D)
                V=NaN;
            else
                V=sum(V)/sum(wV);
            end
            Vint(j,i)=V;
        end
    end

else
    if (r2 > length(vc)) || (r2<1)
        disp('Error: Number of neighbours not congruent with data')
        return
    end
    for i=1:length(x)
        for j=1:length(y)
            D=[]; V=[]; wV =[];vcc=[];
            D= sqrt((x(i)-xc).^2 +(y(j)-yc).^2);
            if min(D)==0
                disp('Error: One or more stations have the coordinates of an interpolation point')
                return
            end
            [D,I]=sort(D);
            vcc=vc(I);
            V = vcc(1:r2).*(D(1:r2).^e);
            wV = D(1:r2).^e;
            V=sum(V)/sum(wV);
            Vint(j,i)=V;
        end
    end
end

return

请提供帮助,非常感谢您的帮助

请建议我如何在数据集中设置插值NaN值的权重和搜索半径。问题是NaN值是随机出现的,并且没有任何顺序。我也不知道文本文件中会出现多少NaN值。请告诉我此解决方案的最佳便捷方式。请尝试发布一个。它确实能帮助人们更快地回答你的问题。正如我所说,MCVE将大大增加人们提供帮助的机会和速度。大代码很吓人,看起来很无聊…谢谢你的帮助。我做了一些修改。如果可以的话,现在请帮忙。太好了,看起来你缩短了不少。编辑还应将您的问题添加到“活动问题”的顶部,以便更多人看到它。不幸的是,我不能亲自帮助你,因为我不懂Matlab。我为任何误解道歉。我在一个审查队列中遇到了这个问题,希望让您知道,使用MCVE可以更快地获得帮助。请建议我如何在数据集中设置插值NaN值的权重和搜索半径。问题是NaN值是随机出现的,并且没有任何顺序。我也不知道文本文件中会出现多少NaN值。请告诉我此解决方案的最佳便捷方式。请尝试发布一个。它确实能帮助人们更快地回答你的问题。正如我所说,MCVE将大大增加人们提供帮助的机会和速度。大代码很吓人,看起来很无聊…谢谢你的帮助。我做了一些修改。如果可以的话,现在请帮忙。太好了,看起来你缩短了不少。编辑还应将您的问题添加到“活动问题”的顶部,以便更多人看到它。不幸的是,我不能亲自帮助你,因为我不懂Matlab。我为任何误解道歉。我在一个回顾队列中遇到了这个问题,我想让您知道,使用MCVE可以更快地获得帮助。
21.500  60.500  295.867
21.500  61.500  295.828
21.500  62.500  295.828
21.500  63.500  295.867
21.500  64.500  296.102
21.500  65.500  296.234
21.500  66.500  296.352
21.500  67.500  296.336
21.500  68.500  296.305
21.500  69.500  298.281
21.500  70.500  301.828
21.500  71.500  302.094
21.500  72.500  299.469
21.500  73.500  301.711
21.500  74.500  -9999.000
21.500  75.500  -9999.000
21.500  76.500  -9999.000
21.500  77.500  -9999.000
21.500  78.500  -9999.000
22.500  60.500  295.477
22.500  61.500  295.484
22.500  62.500  295.516
22.500  63.500  295.547
22.500  64.500  295.852
22.500  65.500  295.859
22.500  66.500  295.852
22.500  67.500  295.711
22.500  68.500  295.969
22.500  69.500  298.562
22.500  70.500  300.828
22.500  71.500  302.352
22.500  72.500  300.570
22.500  73.500  301.383
22.500  74.500  -9999.000
22.500  75.500  -9999.000
22.500  76.500  -9999.000
22.500  77.500  -9999.000
22.500  78.500  -9999.000
23.500  60.500  294.906
23.500  61.500  294.898
23.500  62.500  295.000
23.500  63.500  295.078
23.500  64.500  295.297
23.500  65.500  295.359
23.500  66.500  295.297
23.500  67.500  295.312
23.500  68.500  296.664
23.500  69.500  298.781
23.500  70.500  299.211
23.500  71.500  300.109
23.500  72.500  301.000
23.500  73.500  301.594
23.500  74.500  302.000
23.500  75.500  -9999.000
23.500  76.500  -9999.000
23.500  77.500  -9999.000
23.500  78.500  -9999.000
24.500  60.500  294.578
24.500  61.500  294.516
24.500  62.500  294.734
24.500  63.500  294.789
24.500  64.500  294.844
24.500  65.500  294.562
24.500  66.500  294.734
24.500  67.500  296.367
24.500  68.500  297.438
24.500  69.500  298.531
24.500  70.500  298.453
24.500  71.500  299.195
24.500  72.500  300.062
24.500  73.500  -9999.000
24.500  74.500  -9999.000
24.500  75.500  -9999.000
24.500  76.500  -9999.000
24.500  77.500  -9999.000
24.500  78.500  -9999.000
25.500  60.500  296.258
25.500  61.500  296.391
25.500  62.500  296.672
25.500  63.500  296.398
25.500  64.500  295.773
25.500  65.500  295.812
25.500  66.500  296.609
25.500  67.500  297.977
25.500  68.500  297.109
25.500  69.500  297.828
25.500  70.500  298.430
25.500  71.500  298.836
25.500  72.500  298.703
25.500  73.500  -9999.000
25.500  74.500  -9999.000
25.500  75.500  -9999.000
25.500  76.500  -9999.000
25.500  77.500  -9999.000
25.500  78.500  299.023
26.500  60.500  -9999.000
26.500  61.500  298.266
26.500  62.500  296.773
26.500  63.500  -9999.000
26.500  64.500  -9999.000
26.500  65.500  -9999.000
26.500  66.500  297.250
26.500  67.500  296.188
26.500  68.500  295.938
26.500  69.500  296.906
26.500  70.500  297.828
26.500  71.500  299.312
26.500  72.500  299.359
26.500  73.500  -9999.000
26.500  74.500  -9999.000
26.500  75.500  -9999.000
26.500  76.500  -9999.000
26.500  77.500  298.875
26.500  78.500  296.773
27.500  60.500  -9999.000
27.500  61.500  -9999.000
27.500  62.500  -9999.000
27.500  63.500  -9999.000
27.500  64.500  -9999.000
27.500  65.500  -9999.000
27.500  66.500  -9999.000
27.500  67.500  295.352
27.500  68.500  295.148
27.500  69.500  295.750
27.500  70.500  295.750
27.500  71.500  296.070
27.500  72.500  295.227
27.500  73.500  -9999.000
27.500  74.500  -9999.000
27.500  75.500  -9999.000
27.500  76.500  -9999.000
27.500  77.500  -9999.000
27.500  78.500  296.609
28.500  60.500  -9999.000
28.500  61.500  -9999.000
28.500  62.500  -9999.000
28.500  63.500  -9999.000
28.500  64.500  -9999.000
28.500  65.500  -9999.000
28.500  66.500  -9999.000
28.500  67.500  295.773
28.500  68.500  295.375
28.500  69.500  295.438
28.500  70.500  294.664
28.500  71.500  294.906
28.500  72.500  294.812
28.500  73.500  295.805
28.500  74.500  -9999.000
28.500  75.500  -9999.000
28.500  76.500  -9999.000
28.500  77.500  -9999.000
28.500  78.500  -9999.000
29.500  60.500  -9999.000
29.500  61.500  -9999.000
29.500  62.500  -9999.000
29.500  63.500  -9999.000
29.500  64.500  -9999.000
29.500  65.500  -9999.000
29.500  66.500  -9999.000
29.500  67.500  295.719
29.500  68.500  296.797
29.500  69.500  293.375
29.500  70.500  294.305
29.500  71.500  294.070
29.500  72.500  293.750
29.500  73.500  295.539
29.500  74.500  -9999.000
29.500  75.500  -9999.000
29.500  76.500  -9999.000
29.500  77.500  -9999.000
29.500  78.500  -9999.000
30.500  60.500  -9999.000
30.500  61.500  -9999.000
30.500  62.500  -9999.000
30.500  63.500  -9999.000
30.500  64.500  -9999.000
30.500  65.500  -9999.000
30.500  66.500  -9999.000
30.500  67.500  -9999.000
30.500  68.500  -9999.000
30.500  69.500  -9999.000
30.500  70.500  293.320
30.500  71.500  292.930
30.500  72.500  293.570
30.500  73.500  294.648
30.500  74.500  295.383
30.500  75.500  -9999.000
30.500  76.500  -9999.000
30.500  77.500  -9999.000
30.500  78.500  -9999.000
31.500  60.500  -9999.000
31.500  61.500  -9999.000
31.500  62.500  -9999.000
31.500  63.500  -9999.000
31.500  64.500  -9999.000
31.500  65.500  -9999.000
31.500  66.500  -9999.000
31.500  67.500  -9999.000
31.500  68.500  -9999.000
31.500  69.500  -9999.000
31.500  70.500  293.992
31.500  71.500  293.422
31.500  72.500  294.438
31.500  73.500  294.141
31.500  74.500  -9999.000
31.500  75.500  -9999.000
31.500  76.500  -9999.000
31.500  77.500  -9999.000
31.500  78.500  -9999.000
32.500  60.500  -9999.000
32.500  61.500  -9999.000
32.500  62.500  -9999.000
32.500  63.500  -9999.000
32.500  64.500  -9999.000
32.500  65.500  -9999.000
32.500  66.500  -9999.000
32.500  67.500  -9999.000
32.500  68.500  -9999.000
32.500  69.500  -9999.000
32.500  70.500  -9999.000
32.500  71.500  294.312
32.500  72.500  294.812
32.500  73.500  -9999.000
32.500  74.500  -9999.000
32.500  75.500  -9999.000
32.500  76.500  -9999.000
32.500  77.500  -9999.000
32.500  78.500  -9999.000
33.500  60.500  -9999.000
33.500  61.500  -9999.000
33.500  62.500  -9999.000
33.500  63.500  -9999.000
33.500  64.500  -9999.000
33.500  65.500  -9999.000
33.500  66.500  -9999.000
33.500  67.500  -9999.000
33.500  68.500  -9999.000
33.500  69.500  -9999.000
33.500  70.500  -9999.000
33.500  71.500  -9999.000
33.500  72.500  -9999.000
33.500  73.500  -9999.000
33.500  74.500  -9999.000
33.500  75.500  -9999.000
33.500  76.500  -9999.000
33.500  77.500  -9999.000
33.500  78.500  -9999.000
34.500  60.500  -9999.000
34.500  61.500  -9999.000
34.500  62.500  -9999.000
34.500  63.500  -9999.000
34.500  64.500  -9999.000
34.500  65.500  -9999.000
34.500  66.500  -9999.000
34.500  67.500  -9999.000
34.500  68.500  -9999.000
34.500  69.500  -9999.000
34.500  70.500  -9999.000
34.500  71.500  -9999.000
34.500  72.500  -9999.000
34.500  73.500  -9999.000
34.500  74.500  -9999.000
34.500  75.500  -9999.000
34.500  76.500  -9999.000
34.500  77.500  -9999.000
34.500  78.500  -9999.000
35.500  60.500  -9999.000
35.500  61.500  -9999.000
35.500  62.500  -9999.000
35.500  63.500  -9999.000
35.500  64.500  -9999.000
35.500  65.500  -9999.000
35.500  66.500  -9999.000
35.500  67.500  -9999.000
35.500  68.500  -9999.000
35.500  69.500  -9999.000
35.500  70.500  -9999.000
35.500  71.500  -9999.000
35.500  72.500  -9999.000
35.500  73.500  -9999.000
35.500  74.500  -9999.000
35.500  75.500  -9999.000
35.500  76.500  -9999.000
35.500  77.500  -9999.000
35.500  78.500  -9999.000
36.500  60.500  276.742
36.500  61.500  274.406
36.500  62.500  -9999.000
36.500  63.500  -9999.000
36.500  64.500  -9999.000
36.500  65.500  272.219
36.500  66.500  273.023
36.500  67.500  275.875
36.500  68.500  -9999.000
36.500  69.500  -9999.000
36.500  70.500  -9999.000
36.500  71.500  -9999.000
36.500  72.500  -9999.000
36.500  73.500  -9999.000
36.500  74.500  -9999.000
36.500  75.500  -9999.000
36.500  76.500  -9999.000
36.500  77.500  -9999.000
36.500  78.500  -9999.000
37.500  60.500  277.406
37.500  61.500  277.547
37.500  62.500  276.375
37.500  63.500  275.484
37.500  64.500  276.820
37.500  65.500  275.312
37.500  66.500  274.875
37.500  67.500  275.875
37.500  68.500  -9999.000
37.500  69.500  -9999.000
37.500  70.500  -9999.000
37.500  71.500  -9999.000
37.500  72.500  -9999.000
37.500  73.500  -9999.000
37.500  74.500  -9999.000
37.500  75.500  -9999.000
37.500  76.500  -9999.000
37.500  77.500  -9999.000
37.500  78.500  -9999.000