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

📄 getpt.m

📁 基于MATLAB的辅助设计 简述了矩阵分析的重要性
💻 M
字号:
function [x,y,key]=getpt(fig,choice,ip,an_type);
%
% GETPT is a function which return the coordinat of
% the cursor. It return right coordinat if there are
% two axes on the screen.

%    Author:  Ole Barup Sorensen, Rapid Data Ltd 

%    Copyright (c) 1989-94 by Rapid Data Ltd
%    Revision 10:32  07/02/94


key = 0;
pointer = get(fig,'pointer');
set(gcf,'pointer','crosshair');
fig_units = get(fig,'units');
set(fig,'units','normalized');

keydown = waitforbuttonpress;

ptr_fig = get(0,'CurrentFigure');
if (ptr_fig == fig)
  set([fig 0],'units','pixels');
  scrn_pt = get(0, 'PointerLocation');
  loc = get(fig, 'Position');
  set([fig 0],'units','normalized');
  pt = [scrn_pt(1) - loc(1), scrn_pt(2) - loc(2)];
  if (an_type == 1)|(an_type == 2),
    if (choice == 1)&(an_type == 1)
      if pt(2)<(loc(4)/2), subplot(2,1,2); key=2; else, subplot(2,1,1); key=1; end
    elseif (ip == 3)&(an_type == 2)
      if pt(1)>(loc(3)/2), subplot(1,2,2); key=2; else, subplot(1,2,1); key=1; end
    end 
  end
  ax = gca;
  axu = get(ax,'units');
  set(ax,'units','normalized')
  xlin = strcmp('linear',get(ax,'xscale'));
  ylin = strcmp('linear',get(ax,'yscale'));
  norm_rect = get(ax,'Position');
  handle = ax;
  ydir = get(ax,'ydir');
  ax_lim  = axis;
  if ~xlin, ax_lim(1:2) = log(ax_lim(1:2)); end
  if ~ylin, ax_lim(3:4) = log(ax_lim(3:4)); end
  d_h = ax_lim(4) - ax_lim(3);
  if strcmp(ydir,'reverse'), ax_lim(3) = ax_lim(4); d_h = -d_h; end
  d_w = ax_lim(2) - ax_lim(1);


  ax_rect = [fix(norm_rect(1)*loc(3)),fix(norm_rect(2)*loc(4)),...
    fix(norm_rect(3)*loc(3)),fix(norm_rect(4)*loc(4))];
  pt(1) = (pt(1) - ax_rect(1))/ax_rect(3);
  pt(2) = (pt(2) - ax_rect(2))/ax_rect(4);
  pt(1) = ax_lim(1) + pt(1) * d_w;
  pt(2) = ax_lim(3) + pt(2) * d_h;
  if ~xlin, pt(1) = exp(pt(1)); end
  if ~ylin, pt(2) = exp(pt(2)); end
end

x=pt(1,1);
y=pt(1,2);

set(gcf,'pointer',pointer,'units',fig_units);
set(ax,'units',axu)

% end function

⌨️ 快捷键说明

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