findnearestnode.m

来自「spectral element method」· M 代码 · 共 23 行

M
23
字号
% [xout,yout,iglob,dist] = FindNearestNode(xin,yin,X,Y)%%  PURPOSE	finds the mesh node that is closer to a requested location%%  INPUT	xin,yin	requested receiver locations, can be vectors%		X,Y	global mesh node coordinates%%  OUTPUT	xout,yout	relocated receiver locations	%		iglob	global node indices of relocated receivers%		dist	distance between requested and relocated receivers%function [xout,yout,iglob,dist] = FindNearestNode(xin,yin,X,Y)nseis = length(xin);dist = zeros(nseis,1);iglob = zeros(nseis,1);for k=1:nseis,  [dist(k),iglob(k)] = min( (X-xin(k)).^2+(Y-yin(k)).^2 );enddist = sqrt(dist);xout = X(iglob); yout = Y(iglob); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?