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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • redis分布式锁的应用场景_分布式锁redis实现方式

    redis分布式锁的应用场景_分布式锁redis实现方式RedLock分布式锁 基于Redis实现分布式锁的方式名叫Redlock 安全特性:互斥访问,即永远只有一个client能拿到锁 避免死锁:最终client都可能拿到锁,不会出现死锁的情况,即使原本锁住某资源的clientcrash了或者出现了网络分区(两个完全不连通的区域,美国的网咱们登不上去) 容错性:只要大部分Redis节点存活就可以正常提供服务 Redis集群及应用场景热点数据存取数据优先从Redis操作,如果不存在再从文

    2025年10月7日
    5
  • linux tracker服务器搭建,linux 下 BT Tracker服务器搭建

    linux tracker服务器搭建,linux 下 BT Tracker服务器搭建必须有python2.*以上的环境1、安装bittorrenttarzxvfBitTorrent-3.4.2.tar.gzcdBitTorrent-3.4.2pythonsetup.pyinstall2、启动Bit服务./bttrack.py–port6969–dfiledstate>>/var/log/bttrack.log#表示打开6969并记录log3、制…

    2022年6月25日
    42
  • safari搜索引擎建议需要打开吗_为什么safari用不了谷歌搜索

    safari搜索引擎建议需要打开吗_为什么safari用不了谷歌搜索在使用谷歌搜索引擎的时候会弹出如下页面怎么样才能一步到位,不去点击第二次?第一步:设置」-「Safari」中将默认搜索引擎改为Google第二步:设置地区为香港第三步:看效果

    2025年10月23日
    5
  • centos7怎么退出vi_centos7怎么退出vi

    centos7怎么退出vi_centos7怎么退出vi一、首先用vi命令打卡要编辑的文件:注意:vi命令的使用如下打开或新建文件,并将光标至于第一行首:[root@centos6/]#vi/etc/my.cnf打开文件,并将光标移至最后一行行首:[root@centos6/]#vi+/etc/my.cnf打开文件,并将光标置于第n行首:[root@centos6/]#vi+n/etc/my.cnf打开文件,并将光标置于第一个与pattern匹配的串处…

    2022年9月30日
    2
  • 虚拟化为您打造下一代数据中心

    虚拟化为您打造下一代数据中心

    2021年7月27日
    58
  • C3P0数据库连接池连接Mysql8.0.11的配置问题

    C3P0数据库连接池连接Mysql8.0.11的配置问题C3P0(0.9.5.2)连接Mysql8.0.11的配置问题**小白一个,这几天,在学C3P0数据连接池,把遇到的一些问题记录一下,希望能帮到你们。题主的环境:EclipseC3P0-0.9.5.2可参考这里下载Mysql8.0.11****1.创建配置文件c3p0-config.xml**&amp;amp;amp;amp;amp;lt;?xmlversion=&amp;amp;amp;amp;quot;1.0&am

    2022年5月4日
    72

发表回复

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

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