identify.m

来自「一个非常实用的统计工具箱」· M 代码 · 共 56 行

M
56
字号
function v = identify(x,y,arg3,arg4)%IDENTIFY Identify points on a plot by clicking with the mouse.%%         v = identify(x,y)%%	  This routine plots x versus y and waits for mouse clicks%	  to identify points. Click with left button on points and %	  end with middle button or space bar. Plotsymbol and text %	  strings are optional input arguments. %       Anders Holtsberg, 14-12-94%       Copyright (c) Anders Holtsbergplotsymbol = '*';textvector = 1:length(x);for i = 3:nargin   if i == 3      A = arg3;   else      A = arg4;   end   if max(size(A)) <= 1      plotsymbol = A;    elseif size(A,1) == length(x) | ...         (size(A,1) == 1 & size(A,2) == length(x))            if min(size(A)) == 1          A = A(:);      end      textvector = A;   else      error('Argument incompatibility')   endendif ~isempty(plotsymbol), plot(x,y,plotsymbol); endcx = cov(x);cy = cov(y);v = [];B = 1;while B == 1   [xc,yc,B] = ginput(1);  if B == 1    d = (x-xc).^2/cx+(y-yc).^2/cy;    [d i] = sort(d);    i = i(1);    v = [v; i];    hold on    if isstr(textvector)       text(xc,yc,textvector(i,:));    else       text(xc,yc,sprintf(' %g',textvector(i)));    end  endendhold off

⌨️ 快捷键说明

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