ginput
Records the mouse position(s)/keyboard input(s) in the current figure.
Syntax
[x, y, b] = ginput()
[x, y, b] = ginput(max)
[x, y, b] = ginput('parent', handle)
[x, y, b] = ginput(max, 'parent', handle)
Inputs
- max
 - Maximum number of mouse clicks or keyboard inputs in the current figure to record The GUI will be in a paused state till the max inputs have occured in the current figure area or if the Stop button, return, escape keys or Control + C keys are pressed.
 
- handle
 - Optional input which specifies the handle of a ui element that will be used as a parent (reference) when calculating the ginput positions. The positions printed will be normalized values and can be used when creating GUI elements, which are children of handle.
 
Outputs
- x, y
 - The positions of the mouse/keyboard presses in the current figure.
 - b
 - Information on the button pressed when recording the position(s).
 
Examples
plot(rand(100,1));
[x, y, b] = ginput(3)
x = [Matrix] 1 x 3
18.67280  72.99380  67.43830
y = [Matrix] 1 x 3
0.68790  0.44374  0.86624
b = [Matrix] 1 x 3
1  103  1
f = gcf();
[x, y] = ginput(3, 'parent', f)
p = uipanel(f, 'units', 'normalized', 'position', [x(1), y(1), x(2)-x(1), y(3)-y(2)]);