matlab ginput详解

本文详细介绍了MATLAB中的ginput函数,该函数允许用户通过鼠标点击的方式输入坐标,并提供了多种调用方式来满足不同需求。例如,可以指定获取坐标的数量或是记录鼠标按键信息等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

functions:Graphical input from mouse or cursor

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分别返回的是鼠标所点的坐标。大家可以试试的 ,挺简单的

 

 

转载于:https://www.cnblogs.com/xiaojidan/archive/2012/08/02/2619485.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值