怎么把matlab的程序作出界面,一个简单的matlab图形界面程序GUI

这篇博客介绍如何使用MATLAB代码创建一个简单的图形用户界面(GUI)。通过`showGUI`函数展示了GUI的初始化、回调函数以及界面元素的交互。用户可以通过界面按钮控制显示的内容,包括图像和测试结果。
摘要由CSDN通过智能技术生成

一个简单的matlab图形界面程序GUI

function varargout = showGUI(varargin)

% SHOWGUI MATLAB code for showGUI.fig

%      SHOWGUI, by itself, creates a new SHOWGUI or raises the existing

%      singleton*.

%

%      H = SHOWGUI returns the handle to a new SHOWGUI or the handle to

%      the existing singleton*.

%

%      SHOWGUI('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in SHOWGUI.M with the given input arguments.

%

%      SHOWGUI('Property','Value',...) creates a new SHOWGUI or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before showGUI_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to showGUI_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 showGUI

% Last Modified by GUIDE v2.5 08-Jun-2013 21:53:16

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',      mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @showGUI_OpeningFcn, ...

'gui_OutputFcn',  @showGUI_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

function showGUI_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 showGUI (see VARARGIN)

% Choose default command line output for showGUI

handles.output = hObject;

guidata(hObject, handles);

% UIWAIT makes showGUI wait for user response (see UIRESUME)

% uiwait(handles.showGUI);

% --- Outputs from this function are returned to the command line.

function varargout = showGUI_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 runBut.

function runBut_Callback(hObject, eventdata, handles)

% hObject    handle to runBut (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

maxRunTime = 10;

current_run_no = str2double(get(handles.beginValue, 'String'));

if (get(handles.rdch, 'Value') == get(handles.rdch, 'Max'))

if runtime_number_check(handles, current_run_no) == 1

current_run_no = mod((current_run_no + 1), maxRunTime);

if current_run_no == 0

current_run_no = maxRunTime;

end

set(handles.beginValue, 'String', num2str(current_run_no));

curimno = str2double(get(handles.imgNo, 'String'));

if imgno_number_check(curimno, handles) ~= -1

gui_contents_update(handles, curimno);

end

end

else

running_testfunc(handles);

end

function rdch_Callback(hObject, eventdata, handles)

% hObject    handle to rdch (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

if (get(hObject, 'Value') == get(hObject, 'Max'))

set(hObject, 'String', 'show test results');

else

set(hObject,'String', 'show maps results');

end

current_no = str2double(get(handles.imgNo,'String'));

if imgno_number_check(current_no, handles) == -1

return;

else

gui_contents_update(handles, current_no);

end

guidata(hObject, handles);

function beginValue_Callback(hObject, eventdata, handles)</

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值