我没有发现在GUI和图中使用数据光标之间有任何区别.
重新使用部分代码,我创建了一个GUI,其中一个复选框启用/禁用datacursormode.
GUI包含两个轴,其中分别绘制两条线和3D表面.
此外,还有三个radiobuttons控制将在启用datacursormode时生成的文本框中打印的字符串.
GUI的标签如下:
>左轴:axes_2d
>右轴:axes_3d
>左按钮:pushbutton_2d
>右按钮:pushbutton_3d
>复选框:checkbox_enable_dc
> left radiobutton:radiobutton1
>中间放射线:radiobutton2
> righ radiobutton:radiobutton3
GUI以这种方式工作:
>按钮在轴上绘制并启用复选框
>复选框启用/禁用datacursormode
>默认情况下,左侧单选按钮被选中并设置默认字符串
>另外两个radiobutton设置了不同的字符串
根据选定的单选按钮,文本框中字符串的第一行将是:
>默认字符串
> STRING OPTION ONE
> STRING OPTION TWO
要在文本框中写入的字符串是在myupdatefcn中创建的,该文件已被修改以处理由radiobutton选择的选项.
注意:为了不限制对myupdatefcn函数版本的修改,我对t数组进行了硬编码.
这是GUI的.m文件:
function varargout = gui_datacursormode(varargin)
% GUI_DATACURSORMODE MATLAB code for gui_datacursormode.fig
% GUI_DATACURSORMODE, by itself, creates a new GUI_DATACURSORMODE or raises the existing
% singleton*.
%
% H = GUI_DATACURSORMODE returns the handle to a new GUI_DATACURSORMODE or the handle to
% the existing singleton*.
%
% GUI_DATACURSORMODE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_DATACURSORMODE.M with the given input arguments.
%
% GUI_DATACURSORMODE('Property','Value',...) creates a new GUI_DATACURSORMODE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_datacursormode_OpeningFcn gets called. An
%