我正在尝试用 fileexchange 上的函数替换该函数ginput:ginputc来自
Jiro 的自定义 GINPUT。我发现ginput 第一次调用时启动速度很慢。ginputc是比较快的。
我正在使用的一项功能ginput无法复制ginputc。当鼠标点击它时,我得到了子图号。
此处对此进行了解释ginput:
get-subplot-number-from-ginput
但为了更容易,这里有一些简单的代码来复制功能:
figure, hAx_mine(1)=subplot(1, 3, 1); hAx_mine(2)=subplot(1, 3, 2);hAx_mine(3)=subplot(1, 3, 3);
[x, y, button] = ginput(1);
[Lia,Locb]=ismember(gca,hAx_mine);
disp(['Locb gives the subplot number that you have clicked: ' num2str(Locb)])
如果您在其中尝试相同的操作,ginputc则无论您单击哪个子图,总是给出最后一个子图:
figure, hAx_mine(1)=subplot(1, 3, 1); hAx_mine(2)=subplot(1, 3, 2);hAx_mine(3)=subplot(1, 3, 3);
[x, y, button] = ginputc(1);
[Lia,Locb]=ismember(gca,hAx_mine);
disp(['Locb gives the subplot number that you have clicked: ' num2str(Locb)])
有一个选项可以将斧头作为额外输出ginputc:
...
[x, y, button,ax] = ginputc(1);
[Lia,Locb]=ismember(ax,hAx_mine);
...
但这也行不通。我想这ginputc确实会改变,gca但经过几个小时的尝试,我还没有找到原因以及如何解决它。