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


相关推荐

  • 网络恐怖袭击真实存在吗知乎_911恐怖袭击事件真实过程

    网络恐怖袭击真实存在吗知乎_911恐怖袭击事件真实过程作者:zdnet.co.uk2005-06-0705:0PM网络恐怖主义是一种真的存在的威胁还是仅仅是网络安全日常维护工作中的一种困惑?”我们的敌人将使用我们的技术来和我们做斗争…事实是他们可能来自于第三世界国家,他们不会以任何方式告诉我们,他们不会使用哪些技术以及他们将会用何种方式使用我们的技术。他们将会发现那些我们应该构建安全但是我们没有考虑到的地方,然后他们就会利用这些漏洞。”本

    2022年9月6日
  • 落后的失利王朝死亡

    落后的失利王朝死亡

    2022年1月11日
  • Git拉取代码报密码错误「建议收藏」

    Git拉取代码报密码错误「建议收藏」刚刚Git拉取代码,显示密码错误。我就奇怪了,密码输入了好几次,还是错误。但是马上得提交了,又很着急 ,将最简单的处理 方法忘记了。冷静下来,细细分析。刚学习时好像遇到过此类问题,于是直接删除凭证,再次拉取,正常。真的越着急越乱,遇到问题还是要冷静分析。…

    2022年6月13日
  • webapp开发框架推荐以及优缺点分析【webAPP干货】[通俗易懂]

    webapp开发框架推荐以及优缺点分析【webAPP干货】[通俗易懂]推荐下面6款常用的webapp开发框架。有兴趣可以阅读《HTML5移动webAPP和HybridAPP开发的优缺点分析》和2014年webAPPUI设计和前端JS特效案例集萃第一款:Sencha TouchSenchaTouch是世界上第一个支持HTML5和CSS3标准的移动应用框架,你可以使用HTML5来编写音频和视频组件,还可以使用Lo

    2022年6月15日
  • std future get_waitkey(0)

    std future get_waitkey(0)一、关于std::future成员函数wait_for():1.1关于std::future_status:std::future_status是一个枚举类型,其值有三://ENUMfuture_statusenumclassfuture_status{//namesfortimedwaitfunctionreturnsready,timeout,deferred//延迟执行,当std::async()第一个参数为std::lanuch::de

    2022年9月7日
  • Node.js详细安装教程

    Node.js详细安装教程一、安装环境1、本机系统:Windows10Pro(64位)2、Node.js:v6.9.2LTS(64位)二、安装Node.js步骤1、下载对应你系统的Node.js版本:https://nodejs.org/en/download/2、选安装目录进行安装3、环境配置4、测试三、前期准备1、Node.js简介简单的说Node.js就是运行在服务端的JavaScript。Node.js是一个基于ChromeV8引擎的JavaScript运行环境。Node.js使用

    2022年7月16日

发表回复

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

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