Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function teikna2
- global x y pt;
- f = figure;
- aH=axes('Xlim', [0 1], 'Ylim', [0 1]);
- y=rand(15,1);
- x=1:15;
- h=plot(x,y, ...
- 'color','red',...
- 'lineWidth',3,...
- 'ButtonDownFcn',@startDragFcn);
- set(f,'WindowButtonUpFcn',@stopDragFcn);
- function startDragFcn(varargin)
- set(f,'WindowButtonMotionFcn',@draggingFcn)
- end
- function draggingFcn(varargin)
- pt=get(aH,'CurrentPoint');
- disp([num2str(pt(1)) ' ' num2str(pt(3))]);
- y(abs(x-pt(1))==min(abs(x-pt(1))))=pt(3);
- set(h,'YData',y);
- end
- function stopDragFcn(varargin)
- set(f,'WindowButtonMotionFcn','');
- end
- end
Add Comment
Please, Sign In to add comment