Guest User

Untitled

a guest
May 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.58 KB | None | 0 0
  1. function teikna
  2.  
  3.     f = figure;
  4.    
  5.    
  6.    
  7.     aH=axes('Xlim', [0 1], 'Ylim', [0 1]);
  8.  
  9.     h=line([0.5 0.5],[0 1], ...
  10.         'color','red',...
  11.         'lineWidth',3,...
  12.         'ButtonDownFcn',@startDragFcn);
  13.  
  14.     set(f,'WindowButtonUpFcn',@stopDragFcn);
  15.  
  16.     function startDragFcn(varargin)
  17.         set(f,'WindowButtonMotionFcn',@draggingFcn)
  18.     end
  19.  
  20.     function draggingFcn(varargin)
  21.         pt=get(aH,'CurrentPoint');
  22.         set(h,'XData',[pt(1) 1-pt(1)]);
  23.     end
  24.  
  25.     function stopDragFcn(varargin)
  26.         set(f,'WindowButtonMotionFcn','');
  27.     end
  28. end
Add Comment
Please, Sign In to add comment