⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find_index.m

📁 一个matlab的将军模型
💻 M
字号:
function idx = find_index(v,p)

% Find the index of a point in a vertices object 
%
% Syntax:
%   "i = find_index(vtcs,p)"
%
% Description:
%   "find_index(vtcs,p)" returns the index of "vtcs" where the point "p"
%   is stored.  If "p" is not contained in "vtcs", then
%   "find_index(vtcs,p)" returns "0".
%
% Examples:
%
%
%
%   "a = ["
%
%   "2 2 4 4"
%
%   "1 3 3 1"
%
%   "0 0 0 0];"
%
%   "vtcs = vertices(a);"
%
%   "i = find_index(vtcs,[4 3 0]')"
%
%
%
%   returns 
%
%
%
%   "i = 4"
%
%
%
% See Also:
%   vertices,subsref

global GLOBAL_APPROX_PARAM

point_tol = GLOBAL_APPROX_PARAM.poly_point_tol;

idx = 0;
for k = 1:length(v)
  diff = v.list(:,k)-p;
  if (diff'*diff < point_tol)
    idx = k;
    break;
  end
end

⌨️ 快捷键说明

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