matlab ginput函数

使用ginput()函数使鼠标取点的时候
怎样可以在图上出现标注啊
这我试过了
问题是我准备在两张不同坐标系的图上进行依次标注 一张直角坐标 一张图像像素坐标
如果只是plot的话 在像素坐标的那张图上点击会自动变成直角坐标 原图消失

1、首先打开Matlab,在命令行键入 edit ginput。

2、然后在编辑器标签下找到-保存选项卡,点击下拉三角形,点击另存为,确定即可。

3、然后将函数名称和文件名称对应起来,这里将原来function [out1,out2,out3] = ginput(arg1) 改为 function [out1,out2,out3] = zginput(arg1)。修改完后原来的波浪线会消失。

4、将光标定位到  crossHair 函数附近(大约267行,不同版本可能会有点差异)。

5、将 crossHair 函数下 crossHair(k) =uicontrol(...) 中 BackgroundColor 后面的 [0 0 0] 修改为自己所需的RGB颜色数值(值必须小于等于1)。

6、最后调用该(这里为zginput)函数,具体用法和 ginput 同,修改后的样子如图示。

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2018-02-23
可以用[x,y] = ginput(n)这个函数,n为你想选的点的个数,鼠标点的那些点的横坐标和纵坐标就会保存到[x,y]中。然后再plot(x,y,'*')!应该可以满足你的要求了!本回答被提问者和网友采纳
第2个回答  2017-06-29
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 anaxes 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分别返回的是鼠标所点的坐标。
相似回答