为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

matlab动态标注及定位鼠标坐标代码

2017-09-26 3页 doc 15KB 44阅读

用户头像

is_954223

暂无简介

举报
matlab动态标注及定位鼠标坐标代码matlab动态标注及定位鼠标坐标代码 程序说明:本程序可以实现扑捉画面上鼠标的坐标,可以进行动态标注。 function dynpoint(arg,h) % Show the coordinates of a plot dynamically % % To start use: % dynpoint(h) % where h is a handle to a figure, axes or e.g. line. % % To delete use: % dynpoint('delete',h) % wher...
matlab动态标注及定位鼠标坐标代码
matlab动态标注及定位鼠标坐标代码 程序说明:本程序可以实现扑捉画面上鼠标的坐标,可以进行动态标注。 function dynpoint(arg,h) % Show the coordinates of a plot dynamically % % To start use: % dynpoint(h) % where h is a handle to a figure, axes or e.g. line. % % To delete use: % dynpoint('delete',h) % where h is a handle to a figure, axes or e.g. line. % (you may also use: dynpoint delete) % % There can only be one dynamic plotter in a figure at a time. % % Example: % subplot(211), hline = plot(sin(1:10)) % subplot(212), plot(sin(1:100)) % dynpoint(hline) % 2010,11.30 if ~exist('arg','var') %判断输入变量的个数 arg = gcf; end if ~isstr(arg) handle = arg; arg = 'init'; end switch arg case 'init' if ~ishandle(handle) error('h is not a handle') end [h,ax] = h2hax(handle); % delete old dynamic text object ht = findobj(h,'tag',[mfilename '_text']); if any(ht) delete(ht) end % text window at the bottom left corner % text in centred uicontrol(h,... 'style','text',... 'pos',[10 10 150 30],... 'fontsize',20,... 'tag',[mfilename '_text'],... 'userdata',ax(1)) % do the dynamic thing... set(h,'windowbuttonmotionfcn',[mfilename ' move']) case 'move' ht = findobj(gcbf,'tag',[mfilename '_text']); ax = overobj('axes'); if ~any(ax) ax = get(ht,'userdata'); end p = get(ax,'currentpoint'); p(1); %x坐标值 P(3); %y坐标值 set(ht,'string',sprintf('(%s)','标注')); case 'delete' if ~exist('h','var') h = gcf; end [h,ax] = h2hax(h); set(h,'windowbuttonmotionfcn','') ht = findobj(h,'tag',[mfilename '_text']); delete(ht) end % ---------- function [h,ax]=h2hax(handle) typ = get(handle,'type'); if strcmp(typ,'figure') h = handle; ax = findobj(h,'type','axes'); elseif strcmp(typ, 'axes') h = get(handle,'parent'); ax = handle; elseif strcmp( get(get(handle,'parent'), 'type'), 'axes' ) ax = get(handle,'parent'); h = get(ax,'parent'); End
/
本文档为【matlab动态标注及定位鼠标坐标代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索