⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dynpoint.m

📁 高频地波雷达完整仿真matlab程序 网上找到的
💻 M
字号:
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)


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',[670 8 120 15],...
        'fontsize',9,...
        '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');                                                   % Get handle of object the pointer is over.
    if ~any(ax)
        ax = get(ht,'userdata');
    end
    p = get(ax,'currentpoint');
    set(ht,'string',sprintf('( %d , %0.2f ℃)', round(p(1)), p(3)));

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -