matlab ginput详解

xiaoxiao2021-02-28  79

ginput提供了一个十字光标使我们能更精确的选择我们所需要的位置,并返回坐标值。

函数调用形式为: [x,y] = ginput(n) [x,y] = ginput [x,y,button] = ginput(...)

对于[x,y] =  ginput(n),能使你从当前的坐标系中读取n个点,并返回这n个点的x,y坐标,均为nX1的向量。可以按回车提前结束读数。 [x,y] = ginput 可以无限的读取坐标直到按下回车键。 [x,y,button] = ginput(...)  返回x和y的坐标,以及button值(1=左键,2=中,3=右)或者按键的ASXII码值。

Clicking an axes makes that axes the current axes. Even if you set the current axes before calling ginput, whichever axes you click becomes the current axes and ginput returns points relative to that axes. If you select points from multiple axes, the results returned are relative to the coordinate system of the axes they come from.

example:

>> [x,y,button] = ginput(1)

x =

    0.1118

y =

    0.6623

button =

     1

button返回次数,x,y分别返回的是鼠标所点的坐标。大家可以试试的 ,挺简单的

另例子:

figure axis([100 700 0.2 1.6]);%设定坐标范围 [x1,y1] = ginput(n); plot(x1,y1)

转载请注明原文地址: https://www.6miu.com/read-36051.html

最新回复(0)