[問題] 滑鼠事件程式碼的問題已回收

看板MATLAB作者 (ooman)時間16年前 (2009/08/25 22:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
h=figure('position',[300 150 800 600],... 'name','Demo','menu','figure'); %建立繪圖視窗 a=axes('position',[0.05 0.05 0.7 0.7]); %建立axes物件 set(gcf,'windowbuttondownfcn','mouse(down)') set(gcf,'windowbuttonmotionfcn','mouse(motion)') set(gcf,'windowbuttonupfcn','mouse(up)') function mouse(str) switch str case 'down' %當按下滑鼠的時候 I=get(gca,'CurrentPoint'); %取得座標點 x0=I(1,1); y0=I(1,2); flag=1; case 'motion' if flag==1 I=get(gca,'CurrentPoint'); x1=I(1,1); y1=I(1,2); line([x0,x1],[y0 y1]); %劃線 x0=x1; y0=y1; end case 'up' flag=0 end 我主要是想要利用在視窗中 按下滑鼠後能夠得到座標點 然後整串程式碼的意思是像小畫家繪圖一樣 但是執行的時候總是會出現 ??? Undefined function or variable 'motion'. ??? Error while evaluating figure WindowButtonMotionFcn ??? Undefined function or variable 'motion'. 請問大大問題出在哪呢???? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.98.123 ※ 編輯: r976431852 來自: 61.231.98.123 (08/25 22:32)
文章代碼(AID): #1Aa_J0SQ (MATLAB)
文章代碼(AID): #1Aa_J0SQ (MATLAB)