gdist

버전 1.4.0.0 (11.8 KB) 작성자: Chad Greene
Get distances between points from mouse clicks on a figure.
다운로드 수: 413
업데이트 날짜: 2014/11/20

라이선스 보기

gdist returns the graphical distance between click points from mouse. This function is a modified form of ginput, but differs in that gdist can return distance between each point or cumulative distance along a path of clicked points. gdist gives the user visual confirmation of clicked points, and points can be undone using the backspace key.
Data points are entered by pressing a mouse button or any key on the keyboard except the following:
Carriage return Terminates data entry.
Backspace Deletes previous data point.
z Zooms in, centered on current cursor location.
x Zooms out, centered on current cursor location.

Syntax:
EuclideanDistance = gdist
PathDist = gdist('path')
[...] = gdist(N)
[...] = gdist('color',ColorSpec)
[...,x,y] = gdist(...)
[...,x,y,h] = gdist(...)

Description:
EuclideanDistance = gdist gathers an unlimited number of points until the return key is pressed. Length of EuclideanDistance array is N-1 and is equivalent to EuclideanDistance = diff(PathDist).

PathDist = gdist('path') returns the distance traveled along a path of N clicks. Length of PathDist is equal to the number of clicks N, and the first first value in PathDist will always be zero. PathDist is equivalent to PathDist = [0;cumsum(EuclideanDistance)];

[...] = gdist(N) gets N points from the current axes and returns a vector containing the Euclidean distance from point to point.

[...] = gdist('color',ColorSpec) specifies color of the temporary lines and markers placed on the plot to assist the user.

[...,x,y] = gdist(...) returns x and y coordinates of clicked points.

[...,x,y,h] = gdist(...) returns a handle of line and marker objects clicked by the user. If a handle h is requested, the markers are not automatically removed after the point-entering process has terminated.

Examples:
Any of the inputs described above can be combined in one argument. For example, after plotting some data like this:

plot(sin(1:.01:7),'b')

you can simply type

gdist

to enter as many points as you'd like via mouse clicks. Or if you know ahead of time that you want to enter 4 points, type

gdist(4)

or if you want to calculate the cumulative distance at each step along 4-point path, and you want the temporary guiding lines to be red, type

gdist(4,'path','color','red')

If you'd like to keep that red line in place after using gdist, request the handle h like this:

[pathdist,~,~,h] = gdist(4,'path','color','red');

Then you can delete the red line at your leisure by

delete(h)

For greater precision, type z to zoom in, or x to zoom out. Zooming in or out recenters the plot on the current mouse position. If you accidentally click a point you'd like to undo, click backspace.

인용 양식

Chad Greene (2024). gdist (https://www.mathworks.com/matlabcentral/fileexchange/48489-gdist), MATLAB Central File Exchange. 검색 날짜: .

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

도움 받은 파일: gslope, MYGINPUT, ginput2.m v3.1 (Nov 2009), Custom GINPUT

도움 준 파일: gdistm, clickz

Community Treasure Hunt

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

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

fixed automatic naming.

1.3.0.0

Now supports line colorspec and zooming.

1.2.0.0

fixed automatic naming.

1.1.0.0

Now allows user to undo previous click using the backspace key. Also now includes a cumulative path distance option.

1.0.0.0