Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function test_main
  2. % Plots graph and sets up a custom data tip update function
  3. fig = figure('DeleteFcn','doc datacursormode');
  4. X = 0:60;
  5. t = (X)*0.02;
  6. Y = sin(-16*t);
  7. plot(X,Y)
  8. dcm_obj = datacursormode(fig); % tried here "handles.MyFigHandle"
  9. set(dcm_obj,'UpdateFcn',{@myupdatefcn,t})
  10.  
  11. function txt = myupdatefcn(~,event_obj,t)
  12. % Customizes text of data tips
  13. pos = get(event_obj,'Position');
  14. I = get(event_obj, 'DataIndex');
  15. txt = {['X: ',num2str(pos(1))],...
  16. ['Y: ',num2str(pos(2))],...
  17. ['I: ',num2str(I)],...
  18. ['T: ',num2str(t(I))]};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement