24小时热门版块排行榜    

查看: 1173  |  回复: 3

雨人007

银虫 (小有名气)

[求助] MATLAB 中有关griddata的计算原理,看不懂,求详解!

>>type griddata
function [xi,yi,zi] = gdatav4(x,y,z,xi,yi)
%GDATAV4 MATLAB 4 GRIDDATA interpolation

%   Reference:  David T. Sandwell, Biharmonic spline
%   interpolation of GEOS-3 and SEASAT altimeter
%   data, Geophysical Research Letters, 2, 139-142,
%   1987.  Describes interpolation using value or
%   gradient of value in any dimension.

xy = x( + y(*sqrt(-1);

% Determine distances between points
d = xy(:,ones(1,length(xy)));
d = abs(d - d.');
n = size(d,1);
% Replace zeros along diagonal with ones (so these don't show up in the
% find below or in the Green's function calculation).
d(1:n+1:numel(d)) = ones(1,n);

non = find(d == 0, 1);
if ~isempty(non),
  % If we've made it to here, then some points aren't distinct.  Remove
  % the non-distinct points by averaging.
  [r,c] = find(d == 0);
  k = find(r < c);
  r = r(k); c = c(k); % Extract unique (row,col) pairs
  v = (z(r) + z(c))/2; % Average non-distinct pairs
  
  rep = find(diff(c)==0);
  if ~isempty(rep), % More than two points need to be averaged.
    runs = find(diff(diff(c)==0)==1)+1;
    for i=1:length(runs),
      k = (c==c(runs(i))); % All the points in a run
      v(runs(i)) = mean(z([r(k);c(runs(i))])); % Average (again)
    end
  end
  z(r) = v;
  if ~isempty(rep),
    z(r(runs)) = v(runs); % Make sure average is in the dataset
  end

  % Now remove the extra points.
  z(c) = [];
  xy(c, = [];
  xy(:,c) = [];
  d(c, = [];
  d(:,c) = [];
  
  % Determine the non distinct points
  ndp = sort([r;c]);
  ndp(ndp(1:length(ndp)-1)==ndp(2:length(ndp))) = [];

  warning('MATLAB:griddata:NonDistinctPoints',['Averaged %d non-distinct ' ...
            'points.\n         Indices are: %s.'],length(ndp),num2str(ndp'))
end

% Determine weights for interpolation
g = (d.^2) .* (log(d)-1);   % Green's function.
% Fixup value of Green's function along diagonal
g(1:size(d,1)+1:numel(d)) = zeros(size(d,1),1);
weights = g \ z(;

[m,n] = size(xi);
zi = zeros(size(xi));
jay = sqrt(-1);
xy = xy.';

% Evaluate at requested points (xi,yi).  Loop to save memory.
for i=1:m
  for j=1:n
    d = abs(xi(i,j)+jay*yi(i,j) - xy);
    mask = find(d == 0);
    if ~isempty(mask), d(mask) = ones(length(mask),1); end
    g = (d.^2) .* (log(d)-1);   % Green's function.
    % Value of Green's function at zero
    if ~isempty(mask), g(mask) = zeros(length(mask),1); end
    zi(i,j) = g * weights;
  end
end

if nargout<=1,
  xi = zi;
end
回复此楼
想做的事情挡不住!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

acalephs

捐助贵宾 (著名写手)

哪不懂
2楼2014-12-25 15:34:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

雨人007

银虫 (小有名气)

引用回帖:
2楼: Originally posted by acalephs at 2014-12-25 15:34:41
哪不懂

我想知道V4怎样实现插值的,比如线性插值,是把与插值点靠近的两个数据直接连接,然后在直线上选取对应插值点的数据。V4是根据什么插值的
想做的事情挡不住!
3楼2014-12-26 10:07:04
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

acalephs

捐助贵宾 (著名写手)

引用回帖:
3楼: Originally posted by 雨人007 at 2014-12-26 10:07:04
我想知道V4怎样实现插值的,比如线性插值,是把与插值点靠近的两个数据直接连接,然后在直线上选取对应插值点的数据。V4是根据什么插值的...

参考文献应该有说明吧,其实我也不清楚。。。
4楼2015-01-13 20:01:38
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 雨人007 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 5sJFDKp2kwuI 2026-11-06 10/500 2026-11-08 22:50 by l48hFd8Nwae2
[公派出国] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +4 5sJFDKp2kwuI 2026-11-06 7/350 2026-11-08 22:50 by l48hFd8Nwae2
[硕博家园] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +5 2rKfVQg2jQww 2026-11-06 9/450 2026-11-08 21:55 by l48hFd8Nwae2
[论文投稿] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +5 2rKfVQg2jQww 2026-11-06 9/450 2026-11-08 21:55 by l48hFd8Nwae2
[考研] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +5 5sJFDKp2kwuI 2026-11-06 8/400 2026-11-08 21:51 by l48hFd8Nwae2
[论文投稿] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 5sJFDKp2kwuI 2026-11-06 6/300 2026-11-08 21:44 by l48hFd8Nwae2
[硕博家园] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 5sJFDKp2kwuI 2026-11-06 9/450 2026-11-08 21:29 by l48hFd8Nwae2
[教师之家] 延安大学回应“副教授留绝笔信”:确已离世,正核实举报内容 +3 yexuqing 2026-11-04 5/250 2026-11-07 13:22 by 苏东坡二世
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +8 ncTVBM6AOJHF 2026-11-04 23/1150 2026-11-07 06:49 by Equinoxhua
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +4 ELBZ6WwEaRj6 2026-11-05 7/350 2026-11-06 16:43 by 5sJFDKp2kwuI
[考博] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +6 ELBZ6WwEaRj6 2026-11-05 8/400 2026-11-06 16:34 by 5sJFDKp2kwuI
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +6 ELBZ6WwEaRj6 2026-11-04 11/550 2026-11-06 16:32 by 5sJFDKp2kwuI
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +5 ttH3f1oA6ace 2026-11-04 10/500 2026-11-06 16:12 by 5sJFDKp2kwuI
[公派出国] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +6 ttH3f1oA6ace 2026-11-04 12/600 2026-11-06 16:10 by 5sJFDKp2kwuI
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +8 ncTVBM6AOJHF 2026-11-04 14/700 2026-11-06 13:36 by BkA9Bi5cMhkD
[硕博家园] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 ELBZ6WwEaRj6 2026-11-05 5/250 2026-11-06 09:01 by 2lRNluKrJpwL
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +6 kvewwGtKktqB 2026-11-04 16/800 2026-11-06 05:00 by qL1cU46YIdK0
[硕博家园] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +4 ELBZ6WwEaRj6 2026-11-04 8/400 2026-11-06 02:24 by qL1cU46YIdK0
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +4 ttH3f1oA6ace 2026-11-04 10/500 2026-11-06 02:04 by qL1cU46YIdK0
[硕博家园] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +4 hNpp4Y2CGvSC 2026-11-04 12/600 2026-11-06 01:53 by qL1cU46YIdK0
信息提示
请填处理意见