datatipp.m 514 B

12345678910111213
  1. function output_txt = myfunction(obj,event_obj)
  2. % Display the position of the data cursor
  3. % obj Currently not used (empty)
  4. % event_obj Handle to event object
  5. % output_txt Data cursor text string (string or cell array of strings).
  6. pos=get(event_obj,'Position');
  7. output_txt={['X: ',num2str(pos(1),4)], ['Y: ',num2str(pos(2),4)]};
  8. % If there is a Z-coordinate in the position, display it as well
  9. if length(pos) > 2
  10. output_txt{end+1}=['Z: ',num2str(pos(3),4)];
  11. end
  12. %waitforbuttonpress
  13. end