|
. k) d+ @, P0 u* e
function test_mouse_track()
( x5 A5 ~/ |; M) jfigure;
. H) a( o% j1 F. o8 p" k/ _axis([-10,10,0,5]);, V" ~$ m6 q- N [
myfile = fullfile(tempdir,'position.mat');
6 ^$ Y. s& \3 Jset(gcf,'WindowButtonDownFcn',@ButttonDownFcn);' h6 Q8 R7 o% z9 V+ U
' z" P0 `( i' {: h, I: }9 S/ Y* t
+ g4 ?4 w2 N5 q6 ]. N8 E5 X% 回调函数
% K) L7 k; J8 j- Rfunction ButttonDownFcn(src,event)
# t L- Q: |. jpt = get(gca,'CurrentPoint');
! L7 \% E7 X c$ q9 bx = pt(1,1);
7 |( @; }+ t( v, p' Z8 d$ Jy = pt(1,2);$ n V+ ^! L+ N" f1 ^+ `
save('position.mat','pt','-ascii','-append');
|4 d5 ^7 G* _fprintf('x=%f,y=%f\n',x,y);
6 h2 j: |0 k+ E: a0 j) G2 w0 ~) } O# w0 x
产生的position.mat文件中就是坐标点数据。 |
|