[問題] 滑鼠事件程式碼的問題已回收
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)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章