matlab griddata,MATLAB 中有关griddata的计算原理,看不懂,求详解! – 程序语言 – 小木虫 – 学术 科研 互动社区…

matlab griddata,MATLAB 中有关griddata的计算原理,看不懂,求详解! – 程序语言 – 小木虫 – 学术 科研 互动社区…>>typegriddatafunction[xi,yi,zi]=gdatav4(x,y,z,xi,yi)%GDATAV4MATLAB4GRIDDATAinterpolation%Reference:DavidT.Sandwell,Biharmonicspline%interpolationofGEOS-3andSEASATaltime…

大家好,又见面了,我是你们的朋友全栈君。

>>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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141324.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java集合篇:HashMap原理详解(JDK1.7及之前的版本)

    Java集合篇:HashMap原理详解(JDK1.7及之前的版本)

    2021年10月4日
    31
  • 四位数除以两位数的除法算式_4整除2

    四位数除以两位数的除法算式_4整除2原题链接这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最小的解。提示:一个显然的办法是逐渐增加光棍的位数,直到可以整除x为止。但难点在于,s可能是个非常大的数 ——

    2022年8月8日
    6
  • MySQL 分区表

    MySQL 分区表

    2021年9月11日
    43
  • phpstorm激活码2022【中文破解版】

    (phpstorm激活码2022)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~747EFQ8BIF-eyJsaWNlb…

    2022年3月31日
    68
  • css 首行缩进

    css 首行缩进用CSS实现段落首缩进两个字符,应该使用首行缩进text-indent。比如文本块中一般每段前空两个汉字。在这里我们需要了解一种长度单位em。em是相对长度单位。相对于当前对象(父元素)内文本的字体尺寸。我们中文段落一般每段前空两个汉字。实际上,就是首行缩进了2em。p{ width:200px; text-indent:2em;/*em是相对单位,2em即现在一个字大小的两倍*/}<p> Hi!朋友,感谢您愿意查看猿叔博客。如果您有什么建议或者意见,欢迎联系我,我们互相学习,共

    2025年7月6日
    0
  • SVN—怎样安装SVNserver端软件

    SVN—怎样安装SVNserver端软件

    2022年1月29日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号