zoukankan      html  css  js  c++  java
  • MATLAB-ginput函数问题

    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分别返回的是鼠标所点的坐标。

    Matlab获取鼠标坐标值的ginput()函数

    获取鼠标坐标值的第一种途径:利用Matlab7.0 中

    figure的WindowButtonDownFcn属性。当你在图上按下鼠标的时候,可通过该属性定义一个回调程序。回调程序可以是一个有效的Matlab表达式或者一个M文件。

    那么为显示当前鼠标按下时的坐标值,我们可以将其定义为一个坐标获取和显示程序。

    例如:

    % 主函数

    function test_mouse_track()
    figure;
    axis([-10,10,0,5]);
    set(gcf,'WindowButtonDownFcn',@ButttonDownFcn);

    % 回调函数

    function ButttonDownFcn(src,event)
    pt = get(gca,'CurrentPoint');
    x = pt(1,1);
    y = pt(1,2);
    fprintf('x=%f,y=%fn',x,y);Matlab的ginput()函数

    获取鼠标坐标值的第二种途径:

    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码值。

  • 相关阅读:
    开发错误记录2 .MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    开发错误记录1:解决:Only the original thread that created a view hierarchy can touch its views.
    第二篇 Python初识别及变量名定义规范
    第三篇 Python执行方式和变量初始
    第一篇 Python安装与环境变量的配置
    1. Linux系统常用操作
    Python的内存管理、命名规则、3个特性讲解
    操作系统及Python解释器工作原理讲解
    计算机基础小白篇
    Oracle SQL性能优化
  • 原文地址:https://www.cnblogs.com/lihuidashen/p/3443435.html
Copyright © 2011-2022 走看看