|
4 D8 U7 V" \6 A% p
function test_mouse_track()
; [& D/ `* M* h1 m) i" kfigure;
. Q" z3 a; b5 v0 ~* J9 \axis([-10,10,0,5]);
$ Q" N' Q- Y! i% |. S5 s, z2 N nmyfile = fullfile(tempdir,'position.mat');0 l% ~1 g' O( O1 Z+ u) A7 `% T
set(gcf,'WindowButtonDownFcn',@ButttonDownFcn);
4 x; }1 B k. A T' z0 \2 z/ x
0 e1 n# i( R- \9 j j
$ o7 \4 n- u, N1 h! `& V; F% M% 回调函数- D3 f4 Z0 R5 a& k: |( W/ G$ R
function ButttonDownFcn(src,event)$ X0 W4 O" s) z" H
pt = get(gca,'CurrentPoint');
# m) r/ f7 ^6 I. Kx = pt(1,1);
/ x, l o T$ Y$ u7 `9 my = pt(1,2);
! G% z0 H5 u7 y6 C4 e$ Wsave('position.mat','pt','-ascii','-append');( @8 D. g0 L9 t8 J0 O
fprintf('x=%f,y=%f\n',x,y);3 h8 X+ r- {: U2 `
8 [; H8 ]" f" z
产生的position.mat文件中就是坐标点数据。 |
|