MagnetGInput

버전 1.0.0.0 (1.01 KB) 작성자: Michael Robbins
Returns the position of the closest datapoint to your mouse click.
다운로드 수: 5.6K
업데이트 날짜: 2003/4/18

라이선스 없음

MAGNETGINPUT(h,N,test)
Given the handle of the plot, h, MAGNETGINPUT will either
return the position clicked (upon right button press) or
the location of the datapoint closest to the position
clicked (upon left button press)

If N is provided, MagnetGInput will allow N button clicks

The closest datapoint is determined by minimizing the
distance which is weighted by the scale of the figure,
such that if your figure is [0:1:0:1000], the distance
is

sqrt(((X-x)./1).^2+((Y-y)./1000).^2);

It returns the abscissa and ordinate of the point clicked
or datapoint closest to that point as well as the distance
from the returned position to the click.

If TEST is set true, MAGENETGINPUT will draw a red line
from the click to the closest datapoint and a red circle
using the click as the origin and the distance to the
closest datapoint as a radius

USAGE:

y=sin([.1:.1:10])+rand(1,100).*0.1;
h=plot([1:100],y,'-');
[xin,yin,rin]=MagnetGInput(h);
% click on your plot with the LEFT mouse button
line(xin+[0 10],yin+[0 .5],'color','r');
text(xin+10,yin+.5,{'This datapoint','was the closest to','your mouse click'},'color','r');
hold on;plot(xin,yin,'ro');

IT'S NOT FANCY BUT IT WORKS.

인용 양식

Michael Robbins (2024). MagnetGInput (https://www.mathworks.com/matlabcentral/fileexchange/3265-magnetginput), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R13
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0