function mousetrk
figure
axes('Visible','off')
xbox = uicontrol('Style','text','Tag','xbox');
xboxlabel = uicontrol('Style','text','String','X Value',...
'Position',get(xbox,'position')+[0 21 0 0]);
ybox = uicontrol('Style','text','Position',[90 20 60 20],'Tag','ybox');
yboxlabel = uicontrol('Style','text','String','Y Value',...
'Position',get(ybox,'position')+[0 21 0 0]);
callback = ['pt = get(gca,''CurrentPoint'');'...
'xbox = findobj(''Tag'',''xbox'');' ...
'ybox = findobj(''Tag'',''ybox'');' ...
'set(xbox,''String'',num2str(pt(1,1)));' ...
'set(ybox,''String'',num2str(pt(1,2)));'];
set(gcf,'WindowButtonMotionFcn',callback);
Best Answer