24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1655  |  回复: 2

匿名

用户注销 (初入文坛)

本帖仅楼主可见

» 收录本帖的淘帖专辑推荐

程序

» 猜你喜欢

已阅   同方向广播   申请信息EPI   回复此楼   编辑   查看我的主页

卓别林の忧伤

新虫 (初入文坛)

同求,眼,哈哈哈

发自小木虫IOS客户端
2楼2017-03-25 10:52:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

FMStation

至尊木虫 (知名作家)

【答案】应助回帖

★ ★ ★ ★ ★
感谢参与,应助指数 +1
可胖子: 金币+5, ★★★★★最佳答案 2017-04-04 10:45:17
CODE:
function varargout = ginput_ax_mod2(ha,n)
if nargin<2
    n=1;
end
k = 0;
button = 0;

%%// Tolerance so that in the inifnity case, this could act as
%%// the thresholding distance below which the
%%// input extracting operation must be terminated
TOL = 0.01;

%%// Placeholders for X-Y and button type could be stored
button1 = [];
xy = [];

hf = get(ha,'parent');
figure(hf);
set(hf,'WindowButtonMotionFcn',@changepointer)
set(ha,'ButtonDownFcn',@getpoints)
hp = get(ha,'children');
ht = get(hp,'hittest');
set(hp,'hittest','off')
axlim = get(ha,'Position');
fglim = get(hf,'Position');
x1 = axlim(1)*fglim(3) + fglim(1);
x2 = (axlim(1)+axlim(3))*fglim(3) + fglim(1);
y1 = axlim(2)*fglim(4) + fglim(2);
y2 = (axlim(2)+axlim(4))*fglim(4) + fglim(2);
waitfor(hf,'WindowButtonMotionFcn',[])
if iscell(ht)
    for jj=1:length(ht)
        set(hp(jj),'hittest',ht{jj})
    end
else
    set(hp,'hittest',ht)
end
selType = get(hf,'SelectionType');

% Mouse-Button recognition...
if(strcmp(button, 'normal'))
    button = 1; % left
elseif(strcmp(button, 'extend'))
    button = 2; % right
elseif(strcmp(button, 'alt'))
    button = 3; % middle
else
    button = 4; % double click any mousebutton
end

if nargout==3
    varargout{1} = xy(:,1);
    varargout{2} = xy(:,2);
    varargout{3} = button1(:,1);
elseif nargout==2
    varargout{1} = xy(:,1);
    varargout{2} = xy(:,2);
else
    varargout{1} = xy;
end
    function changepointer(~,~)
        pntr = get(0,'PointerLocation');
        if pntr(1)>x1 && pntr(1)<x2 && pntr(2)>y1 && pntr(2)<y2
            set(hf,'Pointer','crosshair')
        else
            set(hf,'Pointer','arrow')
        end
    end
    function getpoints(src,evnt)
        cp = get(src,'CurrentPoint');
        button = get(hf, 'SelectionType');
        k = k+1;

        if k==1
            xy = [xy ;cp(1,1:2)];
            button1 = [button1; {button}];
        end

        if k>=2
            if pdist2(cp(1,1:2),xy(k-1,:))<TOL && isinf(n)
                k = n;
            else
                xy = [xy ;cp(1,1:2)];
                button1 = [button1; {button}];
            end
        end
        if k==n
            set(hf,'Pointer','arrow')
            set(hf,'WindowButtonMotionFcn',[])
            set(ha,'ButtonDownFcn',[])
            return;
        end
    end
end

CODE:
[x_coords,y_coords,button_types] = ginput_ax_mod2(gca, 10)

3楼2017-03-26 14:54:40
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 可胖子 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 286求调剂 +3 lim0922 2026-03-26 3/150 2026-03-26 23:07 by 不吃魚的貓
[考研] 304材料求调剂 +3 钟llll 2026-03-26 3/150 2026-03-26 23:05 by Dyhoer
[考研] 333求调剂 +7 87639 2026-03-21 12/600 2026-03-26 22:08 by 不吃魚的貓
[考研] 08开头275求调剂 +3 拉谁不重要 2026-03-26 3/150 2026-03-26 20:22 by barlinike
[考研] 一志愿厦门大学化学学硕307求调剂 +8 y7czhao 2026-03-26 8/400 2026-03-26 19:51 by 不吃魚的貓
[考研] 生物学学硕,一志愿湖南大学,初试成绩338 +4 YYYYYNNNNN 2026-03-26 4/200 2026-03-26 19:00 by macy2011
[考研] 材料与化工304求B区调剂 +3 邱gl 2026-03-26 6/300 2026-03-26 18:03 by 邱gl
[考研] 275求调剂 +9 Micky11223 2026-03-25 11/550 2026-03-26 15:54 by 不吃魚的貓
[考研] 263求调剂 +6 yqdszhdap- 2026-03-22 10/500 2026-03-26 13:11 by 公瑾逍遥
[考研] 考研调剂 +6 来好运来来来 2026-03-21 7/350 2026-03-25 22:43 by 418490947
[考研] 311求调剂 +4 勇敢的小吴 2026-03-20 4/200 2026-03-25 18:12 by xcjcqu
[考研] 生物技术与工程 +3 1294608413 2026-03-25 4/200 2026-03-25 18:02 by 1294608413
[考研] 282求调剂 +3 wcq131415 2026-03-24 3/150 2026-03-25 12:16 by userper
[考研] 一志愿北化315 求调剂 +3 akrrain 2026-03-24 3/150 2026-03-24 19:35 by 了了了了。。
[考研] 307求调剂 +5 超级伊昂大王 2026-03-24 5/250 2026-03-24 15:46 by 星空星月
[考研] 085404电子信息284分求调剂 +4 13659058978 2026-03-24 4/200 2026-03-24 12:15 by syl20081243
[考研] 材料/农业专业,07/08开头均可,过线就行 +3 呵唔哦豁 2026-03-23 4/200 2026-03-23 22:30 by 汪!?!
[考研] 293求调剂 +3 涛涛Wjt 2026-03-22 5/250 2026-03-22 22:21 by jiangpengfei
[考研] 311求调剂 +3 26研0 2026-03-20 3/150 2026-03-22 14:46 by ColorlessPI
[考研] 求助 +5 梦里的无言 2026-03-21 6/300 2026-03-21 17:51 by 学员8dgXkO
信息提示
请填处理意见