getmouse.m

来自「麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!」· M 代码 · 共 42 行

M
42
字号
%function [xpos, ypos] = getmouse(marker_str)% function [xpos, ypos] = getmouse(marker_str)% While the left mouse button is pressed down, record the x-y positions, until the button is released.%% marker_str (default '.') is the kind of marker used to plot each pointmarker_str = '.';%if nargin < 1, marker_str = '.'; endxpos = []; ypos = [];figure(1);clfaxis([0 100 0 100])hold on% store pointscmd1 = [ ...    'pos=get(gca,''currentpoint'');' ...    'xpos = [xpos pos(1,1)]; ypos = [ypos pos(1,2)];' ...    'plot(pos(1,1), pos(1,2), marker_str);' ...%    'plot(pos(1,1), pos(1,2), ''.'');' ...%    'set(gcf,''xdata'',pos(1,1),''ydata'',pos(1,2));' ...       ];% resetcmd2 = [ ...    'set(gcf,''windowbuttonmotionfcn'','''');' ...    'set(gcf,''windowbuttonupfcn'','''');' ...%    'set(gcf,''windowbuttonupfcn'',''return;'');' ...       ];cmd3 = [ ...    'set(gcf,''windowbuttonmotionfcn'',cmd1);' ...    'set(gcf,''windowbuttonupfcn'',cmd2);' ...       ];set(gca, 'buttondownfcn',cmd3); %hold off

⌨️ 快捷键说明

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