|
|
+ Q6 B8 Y" M X2 d, ?
function test_mouse_track()
6 T6 I6 e8 c) X# G& h1 }( ~ Afigure;
4 ]* V) h0 b4 R k- s! A; |3 daxis([-10,10,0,5]);# s: R! v' m2 i: f/ S
myfile = fullfile(tempdir,'position.mat');* `) z! c4 U+ o6 N% H. g% U
set(gcf,'WindowButtonDownFcn',@ButttonDownFcn);
, w$ n2 t4 b* P h7 q8 M* T5 }) d9 b- s. T/ i2 o4 K
) B# J$ x t0 a6 f3 K8 ^. Q' W
% 回调函数
+ V4 O. R! ?7 Z2 }- hfunction ButttonDownFcn(src,event)
; s$ b& C* M+ F, b+ p+ \& K; Gpt = get(gca,'CurrentPoint');
2 L7 b. w* j: Y3 l2 |$ P) ^x = pt(1,1);
( h4 ?1 `6 Y. o7 g2 T7 J& P( \y = pt(1,2);
# ?: u. m6 l% |2 U2 lsave('position.mat','pt','-ascii','-append');8 l8 n" o4 w5 }$ x; B+ q3 c
fprintf('x=%f,y=%f\n',x,y);
1 R: \4 m, t0 H8 W6 E
/ y( n1 c$ J. C3 T: Z产生的position.mat文件中就是坐标点数据。 |
|