`
deepfuture
  • 浏览: 4321385 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:79303
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:68105
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:101194
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:280268
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:14535
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:65154
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:31187
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:45071
社区版块
存档分类
最新评论

matlab-GUI程序(3)

 
阅读更多

在打开函数中,增加handles中的字段

function test1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to test1 (see VARARGIN)

% Choose default command line output for test1
handles.output = hObject;

% Update handles structure
handles.numa=1
handles.numb=1
handles.numc=1
guidata(hObject, handles);

% UIWAIT makes test1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

 

 

下面完成将结果赋值

> help guihandles
 GUIHANDLES Return a structure of handles.
    HANDLES = GUIHANDLES(H) returns a structure containing handles of
    objects in a figure, using their tags as fieldnames.  Objects
    are excluded if their tags are empty, or are not legal variable
    names.  If several objects have the same tag, that field in the
    structure contains a vector of handles.  Objects with hidden
    handles are included in the structure.
 
    H is a handle that identifies the figure - it can be the figure
    itself, or any object contained in the figure.
 
    HANDLES = GUIHANDLES returns a structure of handles for the
    current figure.
 
    Example:
 
    Suppose an application creates a figure with handle F, containing
    a slider and an editable text uicontrol whose tags are 'valueSlider'
    and 'valueEdit' respectively.  The following excerpts from the
    application's M-file illustrate the use of GUIHANDLES in callbacks:
 
    ... excerpt from the GUI setup code ...
 
    f = figure;
    uicontrol('Style','slider','Tag','valueSlider', ...);
    uicontrol('Style','edit','Tag','valueEdit',...);
 
    ... excerpt from the slider's callback ...
 
    handles = guihandles(gcbo); % generate handles struct
    set(handles.valueEdit, 'string',...
        num2str(get(handles.valueSlider, 'value')));
 
    ... excerpt from the edit's callback ...
 
    handles = guihandles(gcbo);
    val = str2double(get(handles.valueEdit,'String'));
    if isnumeric(val) & length(val)==1 & ...
       val >= get(handles.valueSlider, 'Min') & ...
       val <= get(handles.valueSlider, 'Max')
      % update the slider's value if the edit's value is OK:
      set(handles.valueSlider, 'Value', val);
    else
      % flush the bad string out of the edit; replace with slider's
      % current value:
      set(handles.valueEdit, 'String',...
        num2str(get(handles.valueSlider, 'Value')));
    end
 
    Note that in this example, the structure of handles is created
    each time a callback executes.  See the GUIDATA help for an
    example in which the structure is created only once, and cached
    for subsequent use.

=================

matlab的一元高次方程数值解

 

 

 

 



 

 

计算结果的程序为:

function btn_draw_Callback(hObject, eventdata, handles)
% hObject    handle to btn_draw (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%求解一元二次方程
myres=roots([handles.numa,handles.numb,handles.numc]);
set(handles.result,'string',mat2str(myres)) ;

 完整程序为

function varargout = test1(varargin)
% TEST1 M-file for test1.fig
%      TEST1, by itself, creates a new TEST1 or raises the existing
%      singleton*.
%
%      H = TEST1 returns the handle to a new TEST1 or the handle to
%      the existing singleton*.
%
%      TEST1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TEST1.M with the given input arguments.
%
%      TEST1('Property','Value',...) creates a new TEST1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before test1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to test1_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help test1
                                            
% Last Modified by GUIDE v2.5 04-Oct-2012 17:21:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @test1_OpeningFcn, ...
                   'gui_OutputFcn',  @test1_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before test1 is made visible.
function test1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to test1 (see VARARGIN)

% Choose default command line output for test1
handles.output = hObject;

% Update handles structure
handles.numa=1
handles.numb=1
handles.numc=1
guidata(hObject, handles);

% UIWAIT makes test1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = test1_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in btn_draw.
function btn_draw_Callback(hObject, eventdata, handles)
% hObject    handle to btn_draw (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%求解一元二次方程
myres=roots([handles.numa,handles.numb,handles.numc]);
set(handles.result,'string',mat2str(myres)) ;

function a_num_Callback(hObject, eventdata, handles)
% hObject    handle to a_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of a_num as text
%        str2double(get(hObject,'String')) returns contents of a_num as a double
numa=str2double(get(hObject,'string'));
if isnan(numa)
      errordlg('请输入数字','输入错误','modal');
end
handles.numa=numa;
guidata(hObject, handles);

      

% --- Executes during object creation, after setting all properties.
function a_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function b_num_Callback(hObject, eventdata, handles)
% hObject    handle to b_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of b_num as text
%        str2double(get(hObject,'String')) returns contents of b_num as a double
numb=str2double(get(hObject,'string'));
if isnan(numb)
      errordlg('请输入数字','输入错误','modal');
end
handles.numb=numb;
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function b_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to b_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function c_num_Callback(hObject, eventdata, handles)
% hObject    handle to c_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of c_num as text
%        str2double(get(hObject,'String')) returns contents of c_num as a double
numc=str2double(get(hObject,'string'));
if isnan(numc)
      errordlg('请输入数字','输入错误','modal');
end
handles.numc=numc;
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function c_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to c_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

 用到的主要知识为:

1、get,set获取和设置属性

2、GUI上的控件,都在handles结构中,比如如果有个edit1的文本编辑框,则在M程序中表示为handles.edit1

3、使用guidata来更新GUI的共享数据,可用于控件之间交换数据,此外要加进handles的结构要在打开函数中增加

4、errordlg显示错误提示框

5、关于gco

 

>> help gco
 GCO Get handle to current object.
    OBJECT = GCO returns the current object in the current figure.
 
    OBJECT = GCO(FIG) returns the current object in the figure FIG.
 
    The current object is the last object clicked on, excluding
    uimenus.  If the click was not over a figure child, the
    figure itself will be the current object.
 
    The handle of the current object is stored in the figure
    property CurrentObject, and can be accessed directly using GET
    and SET.
 
    Use GCO in a callback to obtain the handle of the object that
    was clicked on.  MATLAB updates the current object before
    executing each callback, so the current object may change if
    one callback is interrupted by another.  To obtain the right
    handle during a callback, get the current object early, before
    any calls to DRAWNOW, WAITFOR, PAUSE, FIGURE, or GETFRAME which
    provide opportunities for other callbacks to interrupt.
 
    If no figures exist, GCO returns [].

 

  • 大小: 20.5 KB
  • 大小: 23.1 KB
分享到:
评论

相关推荐

    asp代码ASP基于WEB个人博客网页设计(源代码+论文+答辩)

    asp代码ASP基于WEB个人博客网页设计(源代码+论文+答辩)本资源系百度网盘分享地址

    三菱PLC例程源码打包机

    三菱PLC例程源码打包机本资源系百度网盘分享地址

    asp代码ASP基于USBKEY文件加密工具-USBkey管理系统(源代码+论文)

    asp代码ASP基于USB KEY文件加密工具——USB key管理系统(源代码+论文)本资源系百度网盘分享地址

    Android开发编码规范

    该文档是《阿里巴巴Java开发手册》的规约条目的延伸信息; 其中包含了对内容的适当扩展和解释。它提供了编码和实现方式的正例,以及需要提防的雷区和错误案例的反例。该文档面向Android开发所有成员,旨在规范化代码风格和编程习惯,并提出了针对软件调优的建议。其中包括Android资源文件命名与使用、Android基本组件、UI与布局、进程、线程与消息等方面的内容

    网络安全-逆向学习路线

    红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线红队蓝军逆向学习路线

    which-2.20.tar.gz

    算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

    asp代码ASP基于bs在线花店系统设计(源代码+论文)

    asp代码ASP基于bs在线花店系统设计(源代码+论文)本资源系百度网盘分享地址

    基于深度学习的轨道交通客流实时分析预测系统 第二版(前端).zip

    人工智能毕业设计&课程设计

    解决端口占用netstat -ano

    解决端口占用netstat -ano

    tensorflow_onmttok_ops-0.1.1-cp35-cp35m-manylinux2014_x86_64.whl

    算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

    基于深度学习框架的图像识别:手势识别。使用到:CaffeTensorFlowCNNopenCVcpppythondesign

    人工智能-深度学习-tensorflow

    Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码)

    Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目源码 驴友社交系统 客户端+ 服务器端 (源码) Andorid项目

    JAVA的GUI实现可视化学生管理系统

    JAVA的GUI实现可视化学生管理系统

    WeRoBot-1.5.0-py3-none-any.whl

    Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

    基于ssm小区物业管理系统.zip

    基于ssm小区物业管理系统.zip

    RStudio的15个经典高效快捷操作.pdf

    RStudio的15个经典高效快捷操作

    scratch 0.3 2D我的世界

    鼠标左键:破坏攻击 鼠标右键:放置方块/使用物品 W:前进连按两下W:奔跑 S:后退 A:左移 D:右移 空格键:跳跃 左Shift:潜行 Q:丢弃物品 E:打开背包【Beta1.3版本之前打开背包键为I】 F:调整可视范围【1.8以前版本可用】 T:聊天【多人游戏可用】 双击空格:上升并飞行【创造模式可用】 创造模式飞行中左Shift:下降【创造模式可用】 F1:隐藏界面 F2:截图 F3:查看游戏信息(坐标,帧数,游戏时间,游戏占用内存,等等详细信息) F3+S:游戏无声音时切换出声音 F3+F:调整可视范围【1.8以后版本可用】 F5:第三人称模式 F8:鼠标平滑移动 F11:全屏/窗口切换 1、用石剑攻击三次苦力怕,可以使苦力怕的血量降到最低(建议前期使用,因为前期材料不多,推荐此方法)。 2、用满力(拉满力)的弓攻击苦力怕(两次),此方法简单可靠,你可以在你的屋顶实现,简单高效(建议中期使用,初期的话没有弓与箭,初期建议使用方法一)。 3、用铁剑攻击,这个方法苦力怕的残血值会比方法1高一些,可能骷髅一箭射不死,你的功劳就白费了

    tensorflow_ranking-0.2.3-py2.py3-none-any.whl

    Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

    wheel-0.41.0-py3-none-any.whl

    Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

    tensorflow_serving_api-1.11.1-py2.py3-none-any.whl

    Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。

Global site tag (gtag.js) - Google Analytics