1,在命令行下运行guide命令,在向导中单击Create New GUI,选择Blank GUI(Default);然后在下面选择保存路径,命名文件名为Serial_Port;完成之后点击OK。
2,编辑图形界面,如下图所示,在左侧选择控件,拖到右侧区域中,右键设置属性;
3,编辑源代码,在上面菜单选项中,单击右侧第4个M-file Editor按钮,开始编辑Serial_Port.m文件。
M文件源代码如下所示,请注意控件编号与函数号相对应。
function varargout = Serial_Port(varargin)
% SERIAL_PORT M-file for Serial_Port.fig
% SERIAL_PORT, by itself, creates a new SERIAL_PORT or raises the existing
% singleton*.
%
% H = SERIAL_PORT returns the handle to a new SERIAL_PORT or the handle to
% the existing singleton*.
%
% SERIAL_PORT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SERIAL_PORT.M with the given input arguments.
%
% SERIAL_PORT('Property','Value',...) creates a new SERIAL_PORT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Serial_Port_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Serial_Port_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 Serial_Port
% Last Modified by GUIDE v2.5 17-Jun-2015 10:13:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Serial_Port_OpeningFcn, ...
'gui_OutputFcn', @Serial_Port_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
%