Custom GINPUT

版本 1.0.0.1 (4.6 KB) 作者: Jiro Doke
GINPUT with customizable cursor.
4.9K 次下载
更新时间 2016/9/1

查看许可证

编者注: This file was selected as MATLAB Central Pick of the Week

This function behaves similarly to MATLAB's GINPUT, with an added ability to customize the cursor color, line width, and line style. From the function HELP:
[X,Y] = ginputc(N) gets N points from the current axes and returns the X- and Y-coordinates in length N vectors X and Y. The cursor can be positioned using a mouse. Data points are entered by pressing a mouse button or any key on the keyboard except carriage return, which terminates the input before N points are entered. Note: if there are multiple axes in the figure, use mouse clicks instead of key presses. Key presses may not select the axes where the cursor is.

[X,Y] = ginputc gathers an unlimited number of points until the return key is pressed.

[X,Y] = ginputc(N, PARAM, VALUE) and [X,Y] = ginputc(PARAM, VALUE) specifies additional parameters for customizing. Valid values for PARAM are:
'Color' : A three-element RGB vector, or one of the MATLAB predefined names, specifying the line color. See the ColorSpec reference page for more information on specifying color. Default is 'k' (black).
'LineWidth' : A scalar number specifying the line width. Default is 0.5.
'LineStyle' : '-', '--', '-.', ':'. Default is '-'.
'ShowPoints' : TRUE or FALSE specifying whether to show the points being selected. Default is false.
'ConnectPoints' : TRUE or FALSE specifying whether to connect the points as they are being selected. This only applies when 'ShowPoints' is set to TRUE. Default is true.

[X,Y,BUTTON] = ginputc(...) returns a third result, BUTTON, that contains a vector of integers specifying which mouse button was used (1,2,3 from left) or ASCII numbers if a key on the keyboard was used.

[X,Y,BUTTON,AX] = ginputc(...) returns a fourth result, AX, that contains a vector of axes handles for the data points collected.

Examples:
[x, y] = ginputc;

[x, y] = ginputc(5, 'Color', 'r', 'LineWidth', 3);

[x, y, button] = ginputc(1, 'LineStyle', ':');

subplot(1, 2, 1); subplot(1, 2, 2);
[x, y, button, ax] = ginputc;

[x, y] = ginputc('ShowPoints', true, 'ConnectPoints', true);

引用格式

Jiro Doke (2024). Custom GINPUT (https://www.mathworks.com/matlabcentral/fileexchange/38703-custom-ginput), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2012b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Visual Exploration 的更多信息
致谢

启发作品: gdist, clickz, GINPUT FOR UIAXES, gdistm

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.1

Updated license

1.0.0.0